malc@tahoe.unr.edu (Malcolm L. Carlock) (05/26/88)
Can anyone tell me, or point me to some info describing, how to do a C write() operation to an MS-DOS device (such as PRN, AUX, etc.) ? I have looked through the MicroSoft C V.5.0 manuals, but have found very little, if anything, on this subject. The DOS manual likewise had little or nothing to say about these devices, programming-wise. Neither PRN nor LPT1 are defined in any of the I/O or file-control .h files, nor do they appear in any of the C manual indexes. Thanks in advance, Malcolm L. Carlock ----------------------------------------------------------------- malc@tahoe.unr.edu.UUCP University of Nevada, Reno
nts0302@dsacg3.UUCP (Bob Fisher) (06/01/88)
In article <1318@tahoe.unr.edu>, malc@tahoe.unr.edu (Malcolm L. Carlock) writes: > > How can I do a C write() operation to MS-DOS device PRN, AUX, etc. ? > Try using the pathnames ":PRN", ":CON" and ":AUX" when you open the file. -- - - - - - - - - - - - - - - - - - - - - - - - Bob Fisher @ Defense Logistics Agency Systems Automation Center, Columbus, OH UUCP: {uunet!gould,cbosgd!osu-cis}!dsacg1!bfisher Phone: 614-238-9071 (Autovon 850-9071)
johnl@ima.ISC.COM (John R. Levine) (06/02/88)
In article <875@dsacg3.UUCP> nts0302@dsacg3.UUCP (Bob Fisher) writes: >In article <1318@tahoe.unr.edu>, malc@tahoe.unr.edu (Malcolm L. Carlock) writes: >> How can I do a C write() operation to MS-DOS device PRN, AUX, etc. ? >Try using the pathnames ":PRN", ":CON" and ":AUX" when you open the file. Close but no cigar. You need to use filenames like PRN, AUX, and CON with no colons at all. Be warned that you can use any extension, so if you try to use a file with a name like con.c, you'll get surprising results. -- John R. Levine, IECC, PO Box 349, Cambridge MA 02238-0349, +1 617 492 3869 { ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl, Levine@YALE.something Rome fell, Babylon fell, Scarsdale will have its turn. -G. B. Shaw
doug@gethen.UUCP (Doug Asherman) (06/02/88)
In article <875@dsacg3.UUCP> nts0302@dsacg3.UUCP (Bob Fisher) writes: >In article <1318@tahoe.unr.edu>, malc@tahoe.unr.edu (Malcolm L. Carlock) writes: >> >> How can I do a C write() operation to MS-DOS device PRN, AUX, etc. ? >> > >Try using the pathnames ":PRN", ":CON" and ":AUX" when you open the file. If you do do a "write" to the printer, don't forget to set the mode of the printer to "text". Otherwise you'll end up with a document full of line feeds, but no carriage returns. Or is it the other way around? Oh, well, one of those... If you're using MSC, you can do this two ways: 1) fopen("PRN","wt"); clunky, but it works. 2) setmode(stdprn,O_TEXT); The second method is, I believe, a little better, and you won't have to explicitly open stdprn since it's already open. Come to think of it, if you're going to do a write() anyway, you'll want to use setmode, since write takes a file handle as an argument and stdprn is a pre- defined file handle. -- Current Address: : "You keep using that word- : I do not think it means { sun, ptsfa } : what you think it means." !hoptoad!unisoft!gethen!doug : -William Goldman
boerner@ut-emx.UUCP (Brendan B. Boerner) (06/03/88)
In article <1318@tahoe.unr.edu> malc@tahoe.unr.edu (Malcolm L. Carlock) writes: > >Can anyone tell me, or point me to some info describing, how to do a C write() >operation to an MS-DOS device (such as PRN, AUX, etc.) ? > >I have looked through the MicroSoft C V.5.0 manuals, but have found very >little, if anything, on this subject. The DOS manual likewise had little >or nothing to say about these devices, programming-wise. > >Neither PRN nor LPT1 are defined in any of the I/O or file-control .h files, >nor do they appear in any of the C manual indexes. > >Thanks in advance, I don't know about PRN: or LPTx:, but I tried to access COM0x: as files using MS QuickC and found that I could not get it to work. MS tech support told me that I would need to write some code to read/write to the serial ports as you couldn't open them as files. Hope this helps. Brendan