need code for print. that when you execute i will automatically print to a printer
need code for print. that when you execute i will automatically print to a printer
Which OS?
Which Compiler?
Which Printer?
Are you writing console programs, or GUI programs?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
hmmmm console sir
os = windows 7 and 8
gnu gcc compiler
then to any printer
Depending on how your compiler is configured, you may be able to do this
[code]
fprintf(stdprn,"Hello World\n");
fprintf(stdprn,"\f"); // form feed, print the whole page now
[/code
Or you may need to do this
This should work if you have a printer attached directly to the PC, but if it's some network printer or USB printer, then things might be a bit trickier.Code:FILE *fp = fopen("LPT1:","a"); fprintf(fp,"Hello World\n"); fprintf(fp,"\f"); // form feed, print the whole page now
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.