home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!prism!gt5870c
- From: gt5870c@prism.gatech.EDU (Noah White)
- Newsgroups: comp.sys.mac.programmer
- Subject: THINK C EOF Quest.
- Message-ID: <66973@hydra.gatech.EDU>
- Date: 27 Aug 92 04:54:37 GMT
- Organization: Universal Exports
- Lines: 23
-
-
- I have a program which takes input from the keyboard and terminates with
- an EOF (control-d) yet if I type gggggcontrol-d it drops the curser down to the
- next line without terminating, I have to hit a control-d again to get it
- terminate. However if I type gggg then a return then control-d it terminates.
- Could somone please let me know why this is so? Does this mean that if I were
- to give this a text file as input it would have to be terminated by 2
- control-d's or a carriage return control-d? BTW on the UNIX system it only took
- one control-d.
-
- The code is below:
-
- #include <stdio.h>
-
- main()
- {
- long nc;
-
- nc = 0;
- while (getchar() != EOF)
- ++nc;
- printf("%ld\n", nc);
- }
-