On Oct 30, 12:20 pm, upyzl <zj262...@163.c omwrote:
<snip - code>
Change your loop to look like this:
// scanf line before the loop removed
while (scanf("%d", &nonnega_int ) == 1)
{
// code to calculate factorial
}
This will loop around as long as the user enters valid numbers
(integers).
Bart v Ingen Schenau
Now I change it into:
>
>
I know that now my only problem is "while ( ( nonnega_int =
getchar() ) != EOF )"
but I want to loop as what user want.
Should I add "int loop" or?
>
I must say, I haven't studied about "goto" and of course I don't know
how to use it.
In fact, now I only know use "while ( ( XXXX = getchar() ) != EOF )"
to control loop times,
and I think it should work.
>
What should I do?
getchar() ) != EOF )"
but I want to loop as what user want.
Should I add "int loop" or?
>
I must say, I haven't studied about "goto" and of course I don't know
how to use it.
In fact, now I only know use "while ( ( XXXX = getchar() ) != EOF )"
to control loop times,
and I think it should work.
>
What should I do?
// scanf line before the loop removed
while (scanf("%d", &nonnega_int ) == 1)
{
// code to calculate factorial
}
This will loop around as long as the user enters valid numbers
(integers).
Bart v Ingen Schenau