niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » C
Keyboard stroke for EOF ?
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
one.creepy@gmail.com
*nix forums beginner


Joined: 18 Jul 2006
Posts: 1

PostPosted: Tue Jul 18, 2006 6:48 am    Post subject: Keyboard stroke for EOF ? Reply with 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.

Thanks
C Novice.
Back to top
usenet@zevv.nl
*nix forums Guru Wannabe


Joined: 29 Nov 2005
Posts: 141

PostPosted: Tue Jul 18, 2006 6:59 am    Post subject: Re: Keyboard stroke for EOF ? Reply with quote

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

PostPosted: Tue Jul 18, 2006 7:09 am    Post subject: Re: Keyboard stroke for EOF ? Reply with quote

<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

PostPosted: Tue Jul 18, 2006 11:23 am    Post subject: Re: Keyboard stroke for EOF ? Reply with quote

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

PostPosted: Tue Jul 18, 2006 9:06 pm    Post subject: Re: Keyboard stroke for EOF ? Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 6:45 am | All times are GMT
navigation Forum index » Programming » C
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts bind keyboard POWER button to start some program Vladi Lemurov Debian 1 Fri Jul 21, 2006 6:00 am
No new posts KDM strange keyboard problem Robert Elbracht FreeBSD 2 Thu Jul 20, 2006 9:37 am
No new posts Track keyboard and mouse usage dfaber python 17 Mon Jul 17, 2006 7:12 pm
No new posts Problem with keyboard input for my very little OS pelletier.thomas@gmail.co C 2 Sat Jul 15, 2006 7:11 am
No new posts Keyboard no working after Debian kernel upgrade from 2.4.... Faaiez Sallie Debian 0 Wed Jul 12, 2006 4:40 am

Car Finance | Credit Cards | Web Advertising | The eBay Song | Bankruptcy
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
[ Time: 0.6941s ][ Queries: 16 (0.5794s) ][ GZIP on - Debug on ]