Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
I have a simple little program that reads characters until EOF ...
I have a simple little program that reads characters until EOF, but how do I actually enter that ``EOF'' value from the keyboard? I see that EOF is defined by
✍: Guest
If you think about it, what you enter can't be -1, because ``-1'' is two characters, and getchar is reading one character at a time. It turns out that the value of EOF as seen within your C program has essentially nothing to do with the keystroke combination you might use to signal end-of-file from the keyboard. EOF is essentially a signal to your program that no more characters will be available from that input, for whatever reason (end of a disk file, user is done typing, network stream has closed, I/O error, etc.).
Depending on your operating system, you indicate end-of-file from the keyboard using various keystroke combinations, usually either control-D or control-Z. The operating system and stdio library then arrange that your C program receive the EOF value. (Note, however, that there are various translations involved along the way. Under normal circumstances, you should not explicitly check for the control-D or control-Z value yourself, nor will you find that the
2015-11-16, 1530👍, 0💬
Popular Posts:
Is There Any XSD File to Validate Atom Feed Files? - RSS FAQs - Atom Feed Introduction and File Gene...
What Is a LABEL Tag/Element? - XHTML 1.0 Tutorials - Understanding Forms and Input Fields A "label" ...
What does a well-written Object Oriented program look like? A well-written object oriented program e...
How To Build WHERE Criteria with Web Form Search Fields? - MySQL FAQs - Managing Tables and Running ...
What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y...