home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14594 < prev    next >
Encoding:
Text File  |  1992-08-26  |  939 b   |  33 lines

  1. Path: sparky!uunet!gatech!prism!gt5870c
  2. From: gt5870c@prism.gatech.EDU (Noah White)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: THINK C EOF Quest.
  5. Message-ID: <66973@hydra.gatech.EDU>
  6. Date: 27 Aug 92 04:54:37 GMT
  7. Organization: Universal Exports
  8. Lines: 23
  9.  
  10.  
  11.    I have a program which takes input from the keyboard and terminates with
  12. an EOF (control-d) yet if I type gggggcontrol-d it drops the curser down to the
  13. next line without terminating, I have to hit a control-d again to get it 
  14. terminate. However if I type gggg then a return then control-d it terminates.
  15. Could somone please let me know why this is so? Does this mean that if I were
  16. to give this a text file as input it would have to be terminated by 2 
  17. control-d's or a carriage return control-d? BTW on the UNIX system it only took
  18. one control-d.
  19.  
  20. The code is below:
  21.  
  22. #include <stdio.h>
  23.  
  24. main()
  25. {
  26.     long nc;
  27.     
  28.     nc = 0;
  29.     while (getchar() != EOF)
  30.         ++nc;
  31.     printf("%ld\n", nc);
  32. }
  33.