Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing an output of a program

Status
Not open for further replies.

ah01

Programmer
Jan 29, 2005
4
0
0
US
can I send my output of a consol program to the printer from within vc++ 6.0 or from vC++.net? how? thanks
 
See patterns:
Code:
void CppPrint() // C++ streams
{
  ofstream f("PRN:");
  if (f)
  {
     f << "Hello World!" << endl;
  }
  else
     cerr << "Can\'t open stream on PRN:" << endl;
  // Destructor closes f...
}

void CPrint() /* C FILE* streams */
{
  FILE*	f;
  f = fopen("PRN:","w");
  if (f)
  {
     fprintf(f,"Hello World!\n");
     fclose(f);
  }
  else
     printf("Can\'t open printer file\n");
}
Or try redirect your program stdout output to the printer in command line:
Code:
myprog >prn:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top