#include<stdio.h>
int main(){
int n, scanOK, temp, counter=0;
[B]while(((scanOK=scanf("%d", &n))||1)&&getchar()!=EOF)[/B]
if (scanOK){
for(temp=n;temp/10;temp/=10);
if(!(temp%2)){
printf("%d \n", n);
counter++;
}}
printf("%d \n", counter);
return 0;}My question is, what are the purposes of scanf and getchar() in the bolded line. The scanf receives a string of numbers from the user's keyboard, but what is the information that getchar() gets? Is it the same one as scanOK=scanf("%d", &n) because they are in the same command line? And at what point a character is =EOF. Since the program is with indefinite input arguments, the end-of-file should be typed by the user?
Edited by Alexander, 03 June 2011 - 11:16 PM.
(bbcode formatting)


Sign In
Create Account


Back to top









