📜  将字符串转换为 int - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:40.689000             🧑  作者: Mango

代码示例3
const char *number = "10";
char *end;
long int value = strtol(number, &end, 10); 
if (end == number || *end != '\0' || errno == ERANGE)
    printf("Not a number");
else
    printf("Value: %ld", value);