home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!usc!wupost!udel!gatech!usenet.ins.cwru.edu!agate!rsoft!mindlink!a7657
- From: a7657@mindlink.bc.ca (Stephen H. Kawamoto)
- Subject: how to write C code so that redirection works
- Organization: MIND LINK! - British Columbia, Canada
- Date: Sun, 10 Jan 1993 03:51:36 GMT
- Message-ID: <19456@mindlink.bc.ca>
- Sender: news@deep.rsoft.bc.ca (Usenet)
- Lines: 46
-
- i have a minor problem with C in that when i have a compiled file, FOO
- FOO <infile >outfile
- wont work. it 'hangs' and a ctrl-c or ctrl-break results in the outfile
- having more bytes in it (stuff from the uninitialized memory space i think).
-
- it's the CTOPAS.C source, which turns Pascal into Pascal-like pseudocode (not
- true Turbo Pascal in any case).
-
- here's the main where the problem might lie:
-
- >>
- >> void main()
- >> {
- >> char c, *letter, word[100];
- >> int wordlnth;
- >>
- >> letter=word;
- >> wordlnth=0;
- >> while((c=getchar()) != EOF) {
- >> if(isalpha(c)) letter[wordlnth++]=c;
- >> else {
- >> if(wordlnth>0) { /* word ready to check
- >> */
- >> letter[wordlnth]='\0';
- >> wtest(word); /* pass or replace it
- >> */
- >> wordlnth=0; /* reset index */
- >> }
- >> ctest(c); /* process following
- >> character */
- >> }
- >> }
- >> } /* Note: the last word in the file will be missed if it
- >> followed by EOF with no intervening nonalphanumeric
- >> characters. This is not a problem for Pascal or C source
- >> files. */
-
-
-
- --
- address Email to reach me: <a7657@mindlink.bc.ca>||<an3364@anon.penet.fi>
- "It is the very mind itself
- That leads the mind astray;
- Of the mind,
- Do not be mindless."
- (an old Japanese folk song)
-