can anybody tell me the command to print out a variable straight to the printer please.
p.s (not 'print screen' or 'screen dumps')
thanks.
Printable View
can anybody tell me the command to print out a variable straight to the printer please.
p.s (not 'print screen' or 'screen dumps')
thanks.
Which OS/Compiler?
What type of printer, and what sort of port is it plugged into?
What type of program - console or GUI ?
I came across thisQuote:
Originally Posted by dac
http://support.microsoft.com/default...kb;en-us;23976
im using dev-C++, this is for my AS level coursework project! 'village hall'. have XP at home but NT at school, so needs to work on both.
using the DOS box.
i just need a command which can print my variable text to a printer (reciept).
I am trying to do the same thing. I have tried those tips and nothing happens. These are the codes that I have tried
Code:#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
FILE *stream;
stream = fopen("LPT1", "w");
fprintf(stream, "a line of text\n");
fclose(stream);
cin.get();
return 0;
}
none of these work for me. no errors just nothing prints. I know the printer is working right because I tested it.Code:#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream printer("lpt1");
printer << "a line of text\f" << flush;
cin.get();
return 0;
}
Using DEV-C++ under Windows XP
With an HP Deskjet Printer on lpt1
Does this work?Quote:
none of these work for me. no errors just nothing prints. I know the printer is working right because I tested it.
If so, you can just redirect the output of your program from the command line:Code:C:\>echo Hello, World! > lpt1
BTW, some compilers define a stream called stdprn.Code:C:\>program > lpt1
Code:fprintf(stdprn, "a line of text\n");