从键盘上输入一个数字组成的字符串(字符串长度小于8),将该字符串转换成一个十进制的数。

如题所述

#include "stdio.h"
main()
{ char s[10]; int i;
long int n=0;

/**************found************/
scanf("%s",s);
/**************found************/
for(i=0;s[i]!='\0';i++)
n=n*10+s[i]-'0';
printf("n=%ld\n",n);
}
温馨提示:答案为网友推荐,仅供参考