468,496 Members | 1,796 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,496 developers. It's quick & easy.

Keyboard stroke for EOF ?

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.

Jul 18 '06 #1
4 42366
Ico
on********@gmail.com wrote:
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

--
:wq
^X^Cy^K^X^C^C^C^C
Jul 18 '06 #2

<on********@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
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

Jul 18 '06 #3
On 17 Jul 2006 23:48:16 -0700, in comp.lang.c , on********@gmail.com
wrote:
>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
Jul 18 '06 #4
Mark McIntyre <ma**********@spamcop.netwrites:
On 17 Jul 2006 23:48:16 -0700, in comp.lang.c , on********@gmail.com
wrote:
>>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!
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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Steve Jorgensen | last post: by
6 posts views Thread by DS | last post: by
reply views Thread by Nadav | last post: by
reply views Thread by Omkar Mate | last post: by
13 posts views Thread by Hema | last post: by
4 posts views Thread by giannis | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.