home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!utcsri!relay.cs.toronto.edu!compuserve.com!76336.3114
- Newsgroups: comp.lang.c++
- From: 76336.3114@CompuServe.COM (Kevin Dean)
- Subject: Piping and return code
- Message-ID: <930101234017_76336.3114_EHJ42-3@CompuServe.COM>
- Date: 1 Jan 93 23:47:40 GMT
- Lines: 21
-
- In an article dated Dec. 30, Binh Tong (tongb@woods.ulowell.edu) asks:
-
- >Does any one know how to put redirect output and get return code in C ?
-
- The ANSI-standard function freopen() followed by the appropriate spawn
- command can be used as follows:
-
- FILE * newIn = freopen("LOGIN.IN", "r", stdin); // Redirect input.
- int result = spawn...("LOGIN.EXE", ...); // Run command.
- freopen("CON", "r", stdin); // Restore input.
-
- It's been a while since I did this so it may need some fiddling but I know
- for certain that freopen() will work. Share and enjoy.
-
- Kevin Dean
-
- SNAG: acronym for Sensitive New-Age Goof, one who, without any relevant
- experience, is always willing to enlighten the ignorant masses on the
- social issue of the day. Have you hit any SNAGs lately?
-
-
-