#include <stdio.h>
void main() {
int stoi(char str[]);
char str[10];
printf("input a digit string:\n");
scanf("%s", str);
printf("\nThe value is :%d", stoi(str));
}
int stoi(char str[]) {
int value = 0, i = 0;
while(str[i] != '\0') {
value = value * 10 + str[i] - 48;
i++;
}
return(value);
}
字符型数字转换成数值型
最新推荐文章于 2024-04-13 06:04:17 发布