Keyboard stroke for EOF ?

O

one.creepy

What would be the keyboard stroke for EOF?

while((c=getchar())!=EOF) printf("%c",c);

what would cause the program to come out of the while loop?I am using
the compiler that comes with SDK.

Thanks
C Novice.
 
I

Ico

What would be the keyboard stroke for EOF?

while((c=getchar())!=EOF) printf("%c",c);

what would cause the program to come out of the while loop?I am using
the compiler that comes with SDK.

The EOF code is not really generated by a key; usually it is your
operating system that handles the key, and stops reading the file. This
generates the end-of-file, which is handled by your if.

You say nothing about the OS or platform you are running on, but you
could try Ctrl-D or Ctrl-Z
 
R

Rod Pemberton

What would be the keyboard stroke for EOF?

while((c=getchar())!=EOF) printf("%c",c);

what would cause the program to come out of the while loop?I am using
the compiler that comes with SDK.

It varies by environment. Try ctrl-Z (Windows/DOS), ctrl-D (Unices). If
those don't work, try one of these ctrl-T, ctrl-Y, ctrl-V, ctrl-M (I don't
know if they actually do anything though...).

Sorry if I sound bitter, but...

Seriously, how long does it take to test all keystrokes? (Not long, I did
so many years ago...)

How hard is it to go to www.wikipedia.org and enter EOF?
http://en.wikipedia.org/wiki/End-of-file

How hard is it to go to Google Groups Advanced Search, enter comp.lang.c and
eof?
http://groups.google.com/advanced_search?hl=en



Rod Pemberton
 
M

Mark McIntyre

What would be the keyboard stroke for EOF?

EOF isn't a character, its a condition. How you generate it depends on
your operating system, but control-D and control-Z are popular
selections.
while((c=getchar())!=EOF) printf("%c",c);

what would cause the program to come out of the while loop?

Generating an EOF condition!
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
K

Keith Thompson

Mark McIntyre said:
EOF isn't a character, its a condition. How you generate it depends on
your operating system, but control-D and control-Z are popular
selections.


Generating an EOF condition!

To be painfully precise, end-of-file is a condition; EOF is a macro,
expanding to a negative integer constant (typically -1), whose value
is returned by certain functions when an end-of-file condition (or an
error condition) is encountered.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top