|
|
|
|
|
|
| Author |
Message |
one.creepy@gmail.com *nix forums beginner
Joined: 18 Jul 2006
Posts: 1
|
Posted: Tue Jul 18, 2006 6:48 am Post subject:
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. |
|
| Back to top |
|
 |
usenet@zevv.nl *nix forums Guru Wannabe
Joined: 29 Nov 2005
Posts: 141
|
Posted: Tue Jul 18, 2006 6:59 am Post subject:
Re: Keyboard stroke for EOF ?
|
|
|
one.creepy@gmail.com wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
Rod Pemberton *nix forums Guru
Joined: 19 Jan 2006
Posts: 353
|
Posted: Tue Jul 18, 2006 7:09 am Post subject:
Re: Keyboard stroke for EOF ?
|
|
|
<one.creepy@gmail.com> wrote in message
news:1153205296.266454.76180@m73g2000cwd.googlegroups.com...
| Quote: | 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 |
|
| Back to top |
|
 |
Mark McIntyre *nix forums Guru
Joined: 16 Feb 2005
Posts: 1564
|
Posted: Tue Jul 18, 2006 11:23 am Post subject:
Re: Keyboard stroke for EOF ?
|
|
|
On 17 Jul 2006 23:48:16 -0700, in comp.lang.c , one.creepy@gmail.com
wrote:
| Quote: | 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.
| Quote: | 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 |
|
| Back to top |
|
 |
Keith Thompson *nix forums Guru
Joined: 28 Feb 2005
Posts: 5173
|
Posted: Tue Jul 18, 2006 9:06 pm Post subject:
Re: Keyboard stroke for EOF ?
|
|
|
Mark McIntyre <markmcintyre@spamcop.net> writes:
| Quote: | On 17 Jul 2006 23:48:16 -0700, in comp.lang.c , one.creepy@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) kst-u@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. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 7:01 am | All times are GMT
|
|
Loans | Internet Advertising | Photography | MySpace Layouts | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|