R
Richard Heathfield
Army1987 said:
No, of course not. There are plenty of ways you could do this...
....for example, you could write five lines of code instead of one, and
still fail to deal with EOF correctly.
"Richard Heathfield" ha scritto...
if(fgets(Yes_No, sizeof Yes_No, stdin) != NULL && Yes_No[0] == 'y')
Is it necessary?
No, of course not. There are plenty of ways you could do this...
I'd just use:
int answer;
int ch;
and then:
answer = getchar();
do {
ch = getchar();
} while (ch != '\n' && ch != EOF);
if (answer == 'y' || answer == 'Y') {
....for example, you could write five lines of code instead of one, and
still fail to deal with EOF correctly.