Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does EOF mean?

 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this is the code...which i got from the net....but i dont seem to understand it..what does EOF mean here? and what is the ideal output here?

this code is supposed to count the number of words

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
end of file
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so when i run this program i get a console window which never seems to stop...i want to stop the input as soon enter is pressed...how do i do it?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EOF is a constant that is defined in the stdio.h file and used for the end of file value. For more Google can help.

A decent google hit
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happens if ctrl-d is pressed? i dont get any different answer...just a new character...but nothing happens becuase of it
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember correctly, and I probably don't, EOF is ctrl-D on Mac and *nix, but ctrl-Z or ctrl-Z/return on Windows and DOS.
 
isha krishnan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all!!

now if we check the value of EOF inn stdio.h,its -1..
when i type characters on console which are read by getchar()..if i enter -1 in that string eg "abc-1dd"

i get the output with putchar(c) as abc-1dd.

why does not it stop at -1 itself since (-1 = EOF)?

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you enter an end-of-file character?
 
isha krishnan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had not entered character,now i tried with ctrl+z on output window .It helped to get out of output screen and counted the number of lines correctly.

Thanks
 
Riiya Dsesuja
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EOF is "End Of File"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic