Hello
I have been trying to make a function that can send the output data or any text to a network printer, I read many articles/posts about it but nothing is working, have been looking for almost a week...
Whenever the program tries to use the printer function, it either hangs or gives the "failed to open file" message.
It would be really appreciated if someone can give me a hand here, oh and the OS I'm using is Windows XP. and I would prefer if I didn't have to use the MFC or the Windows API if possible, but if this is the only way then it's OK.
Here is a sample of the code that I tried:
#include <fstream.h>
#include <iostream.h>
int main()
{
ofstream printer( "prn" ); //I also tried to replace prn with LPT1
if (!printer)
{
cout << "Failed to open file\n";
return 0;
}
printer << "Hello world!\n";
printer.close();
return 0;
}