Dear Friends, can anyone help to print a text to default printer in c++? ex:- Code: #include <iostream> using namespace std; int main() { cout<<"Hello World!!!"<<endl; return 0; } in the above example i would like to print the Hello World!!! in a physical printer connected to my system. pls share the sample code.
What operating system are you using? It's different for each one. And what API are you using? It is also different for each one of those.
Hi, i'm using Windows 7 as the OS, and using Dev C++ compiler environment, please i'm new to programming and update the above code post it.
If you're new to programming then I'm pretty certain this'll be beyond you. Your best bet is to write to a file, open it in Notepad, then use the File Print menu from there. If you don't believe me then have a look at the code here: https://support.microsoft.com/en-us/kb/186736 When you can understand what that code is doing, then you'll be able to adapt it to your needs.
Hey, try this code : Code: #include<iostream.h> #include<fstream.h> #include<stdlib.h> #include<conio.h> main(int argc,char *argv[]) { clrscr(); if(argc!=2) { cout<<"\n Format : File - Print File Name "<<endl; exit(0); } char ch='\0'; ifstream input_file; ofstream output_file; input_file.open(argv[1]); output_file.open("PRN"); // or LPT1while(input_file.get(ch)!=0); output_file.put(ch); getch(); return 0; }