home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19487 < prev    next >
Encoding:
Text File  |  1993-01-09  |  1.7 KB  |  57 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!usc!wupost!udel!gatech!usenet.ins.cwru.edu!agate!rsoft!mindlink!a7657
  3. From: a7657@mindlink.bc.ca (Stephen H. Kawamoto)
  4. Subject: how to write C code so that redirection works
  5. Organization: MIND LINK! - British Columbia, Canada
  6. Date: Sun, 10 Jan 1993 03:51:36 GMT
  7. Message-ID: <19456@mindlink.bc.ca>
  8. Sender: news@deep.rsoft.bc.ca (Usenet)
  9. Lines: 46
  10.  
  11. i have a minor problem with C in that when i have a compiled file, FOO
  12. FOO <infile >outfile
  13. wont work. it 'hangs' and a ctrl-c or ctrl-break results in the outfile
  14. having more bytes in it (stuff from the uninitialized memory space i think).
  15.  
  16. it's the CTOPAS.C source, which turns Pascal into Pascal-like pseudocode (not
  17. true Turbo Pascal in any case).
  18.  
  19. here's the main where the problem might lie:
  20.  
  21. >>
  22. >> void main()
  23. >> {
  24. >>    char c, *letter, word[100];
  25. >>    int wordlnth;
  26. >>
  27. >>    letter=word;
  28. >>    wordlnth=0;
  29. >>    while((c=getchar()) != EOF) {
  30. >>       if(isalpha(c)) letter[wordlnth++]=c;
  31. >>       else {
  32. >>          if(wordlnth>0) {            /* word ready to check
  33. >> */
  34. >>             letter[wordlnth]='\0';
  35. >>             wtest(word);             /* pass or replace it
  36. >> */
  37. >>             wordlnth=0;              /* reset index */
  38. >>          }
  39. >>          ctest(c);                   /* process following
  40. >> character */
  41. >>       }
  42. >>    }
  43. >> }   /* Note:  the last word in the file will be missed if it
  44. >> followed by EOF with no intervening nonalphanumeric
  45. >> characters.  This is not a problem for Pascal or C source
  46. >> files.  */
  47.  
  48.  
  49.  
  50. --
  51. address Email to reach me: <a7657@mindlink.bc.ca>||<an3364@anon.penet.fi>
  52.     "It is the very mind itself
  53.      That leads the mind astray;
  54.      Of the mind,
  55.      Do not be mindless."
  56.      (an old Japanese folk song)
  57.