C语言程序设计题 字符串转数值

2025-03-31 03:24:06
推荐回答(3个)
回答1:

因为srtlen会把'\0'作为字符串结束标志而不算在字符串长度中。同时后面的字符就不算了。因为一般字符串都是以'\0'作为结束的,你使用printf("%s",st);也会只输出前面的hello

回答2:

int stoi( char * input ){
int result = 0;
if( input != 0 ){
while( *input != '\0' ){
if( *input >= '0' && *input <= '7' ){
result = result*8 + (*input - '0');
}
input++;
}
}
return result;
}

回答3:

输入样例
a b12c 3d
输出样例
83这个是怎么转换的,没看懂