Showing posts with label EOF. Show all posts
Showing posts with label EOF. Show all posts

Wednesday, May 13, 2015

About EOF (End of file) in C

Have you ever wondered what is EOF in "Exiting c program right after reading one line or after carriage return while reading input from stdin".

EOF (End of the file) is a macro which expands to an integer constant expression with type int and an implementation dependent negative value but is very commonly -1.

Below is a small snippet to print EOF in c.
 #include <stdio .h="">  
 int main()  
 {  
 printf("\n Value of EOF is %d\n",EOF);  
 return 0;  
 }  

Output of this program is:

 mrtechpathi@mrtechpathi:~/Study/C/K_and_R$ ./a.out   
  Value of EOF is -1