int main(void)
{
char input[MAXLEN];
int n = 0, num = 0;
while (1)
{
input[n] = getch();
if (input[n++] == 13 || n >= MAXLEN - 1) break;
}
input[n] = '\0';
num = atoi(input);
printf("your input is :%d\n", num);
return 0;
}
CFREE4.1通过。
int main()
{ int number=0,n=1;
int i,j;
char c[20];
i=-1;
do
{ i++;
c[i]=getch();
if(c[i]!=10)
putchar('*');
}while(c[i]!=10);
for(j=i-1;j>=0;j--)
{
number=number+(c[j]-48)*n;
n=n*10;
}
printf("\nthe number * is %d\n",number);
return 0;
}