-
verify EOF
hi
please have a look at the following code.
Code:
#include<stdio.h>
#include<conio.h>
main ()
{
int c;
while((c=getchar()) !=EOF)
putchar(c);
getch();
}
how do i verify that the expression getchar() !=EOF is zero or one?
AND :D how do i print the value of EOF?
threadhead
-
>how do i verify that the expression getchar() !=EOF is zero or one?
If putchar ( c ); executes then the expression is one. You can say something like this, though that would be a bit silly:
Code:
int chk_bool = ( ( c = getchar() ) != EOF );
while ( chk_bool != 0 ) {
putchar ( c );
chk_bool = ( ( c = getchar() ) != EOF );
}
>how do i print the value of EOF?
Code:
#include <stdio.h>
int main ( void )
{
printf ( "%d\n", EOF );
return 0;
}
Though once again, there's little point in doing this.
-Prelude