#include <stdio.h>
long cton(void)
{ char c;
long s=0;
c=getchar();
while(c>='0'&&c<='9')
{s=s*10+c-'0';}
return (s);
}
void main()
{ printf("input a line of numeric character:");
printf("%ld\n",cton());
}
老师给的答案,怎么不行呢?
其实这段代码一大半是我自己敲的,谢谢你的忠告。