C++ code for printing

Hello,

I'm looking, and I haven't been successful, to be able to print (from an actual printer) a .txt file, using notepad. Any direction given towards this topic would be greatly appreciated. Thank you.
c++ does not know printers. You have to have an API to the driver, which is likely in your OS but you need the hooks into your program with some kind of library, OR, you can print it by redirection. Visual studio has really easy hooks in windows to tap the window's drivers, but its nonstandard -- you just add a print dialog to your program and it pops up the usual windows printer utility.
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
   string filename = __FILE__;     // for example, this file
   string cmd = "notepad /p " + filename;
   system( cmd.c_str() );
}
lastchance, ty. worked like a dream. i do appreciate it.
Topic archived. No new replies allowed.