PDA

View Full Version : Printer



Gerard Fremaint
09-07-2002, 09:43 AM
Is there a way for me to print to the printer with C Programming in DOS ?

Unimatrix139
09-07-2002, 09:49 AM
I'm not exactly a C wizard, and I can't program using ports. I'd write all the data to a file and use:-


system("copy file.ext prn");
or

system("type file.ext >prn");
Basically this is getting DOS to do the work for you. And if you aren't using pure DOS (Running COMMAND.COM under Windoze) I'm not sure Windoze will like it. :D

moi
09-07-2002, 10:24 AM
Originally posted by Unimatrix139
I'm not exactly a C wizard, and I can't program using ports. I'd write all the data to a file and use:-


system("copy file.ext prn");
or

system("type file.ext >prn");
Basically this is getting DOS to do the work for you. And if you aren't using pure DOS (Running COMMAND.COM under Windoze) I'm not sure Windoze will like it. :D

i don't know if those particular commands are valid, but printing to the printer using dos stuffs under windoze 98 works for me.

civix
09-07-2002, 11:38 AM
I once heard that you need to write to drivers, otherwise, im not the best person to ask.

Dr. Bebop
09-07-2002, 12:18 PM
There are a bunch of ways in DOS, here are two


#include <stdio.h>
main()
{
fprintf( stdprn, "Something to print\n" );
}

#include <stdio.h>
main()
{
FILE *stream;

stream = fopen( "PRN", "w" );
fprintf( stream, "Something to print\n" );
}

Bebop

Driveway
09-07-2002, 01:55 PM
Deosn't work with USB printers though

???
09-08-2002, 03:00 AM
>> Deosn't work with USB printers though

change "PRN" to "LPT1".

Unimatrix139
09-08-2002, 03:47 AM
LPT1 and PRN are pretty much identical - LPT1 is the id for Parallell port 1 and PRN is the default parallell port (almost always LPT1) - Anyway, I don't think you can address LPT1 from C with fprintf, etc.