Xref: utzoo comp.unix.questions:25175 comp.misc:9991 Path: utzoo!utgpu!watserv1!watmath!att!dptg!lzga!bogatko From: bogatko@lzga.ATT.COM (George Bogatko) Newsgroups: comp.unix.questions,comp.misc Subject: Re: File I/O with lex/yacc Keywords: lex, yacc, file i/o Message-ID: <2033@lzga.ATT.COM> Date: 30 Aug 90 12:22:33 GMT References: <2320@cirrusl.UUCP> <1990Aug29.122152.1600@virtech.uucp> <1990Aug29.172830.14348@cunixf.cc.columbia.edu> Organization: AT&T BL Middletown/Lincroft NJ USA Lines: 25 In article <1990Aug29.172830.14348@cunixf.cc.columbia.edu>, gld@cunixd.cc.columbia.edu (Gary L Dare) writes: > > Is there any way to get around the use of standard input/output in a > lex file??? The C file generated by lex (from the lexical analyzer There are two ways. 1. Use freopen(...stdin) freopen(...stdout). freopen("your_in_file", "r", stdin); freopen("your_out_file", "w", stderr; 2. use a close/open combination, ala: close(0); open("your_in_file", ...); close(1); open("your_out_file", ...); blah, blah, blah. the second way can be useful if you want to use lex to parse the input from a tty line different than your terminal line. Method 1 is far less messy than method 2. GB