Hi guys,
I'm confusing about getchar() while reading Ritchie Kerninghans book.
while this one loops as my 2.4Ghz can
Ex1
but this. just waits and prints input for input on every [ENTER]:
Ex2
shouldn't be getchar() outside a while just a "oneShot" and inside like
in the second example loop as the first one?
And why dosnt Ex1 starts print immidiately but right after hitting [ENTER]?
thanks.
S.
I'm confusing about getchar() while reading Ritchie Kerninghans book.
while this one loops as my 2.4Ghz can
Ex1
c = getchar();
while( c != EOF ) {
++g;
if ((g % 1000000000) == 0) {
printf("%lld\n",g);
}
if(g > 10000000000)
break;
}
but this. just waits and prints input for input on every [ENTER]:
Ex2
while ((c = getchar()) != EOF){
++f;
printf("c:%c.",c);
if ( f > 1000)
break;
//putchar(c);
}
shouldn't be getchar() outside a while just a "oneShot" and inside like
in the second example loop as the first one?
And why dosnt Ex1 starts print immidiately but right after hitting [ENTER]?
thanks.
S.