Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,177 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,001 people online right now. Registration is fast and FREE... Join Now!




Printing files

 
Reply to this topicStart new topic

Printing files

aj32
5 Sep, 2007 - 11:50 AM
Post #1

D.I.C Addict
Group Icon

Joined: 30 Aug, 2007
Posts: 577



Thanked: 2 times
Dream Kudos: 675
My Contributions
HI! I am programing in C++. Just out of curiosity, Is there an inbuilt way to print a file or variable. I tried using system("print...") command but I can't get it to work.
-Thanks
User is offlineProfile CardPM
+Quote Post

MorphiusFaydal
RE: Printing Files
5 Sep, 2007 - 12:54 PM
Post #2

D.I.C Lover
Group Icon

Joined: 12 May, 2005
Posts: 1,104



Thanked: 8 times
Expert In: Hardware, Networking

My Contributions
Do you mean like displaying to the screen?

Reading files: Look up fstream (ifstream,ofstream)

Printing to the screen: cout

You should cover both of these in about the first few chapter of any book...
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Printing Files
5 Sep, 2007 - 01:09 PM
Post #3

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
If you're referring to outputting to a printer, there is no inherent command, as different platforms have different accesses.
User is offlineProfile CardPM
+Quote Post

aj32
RE: Printing Files
5 Sep, 2007 - 02:00 PM
Post #4

D.I.C Addict
Group Icon

Joined: 30 Aug, 2007
Posts: 577



Thanked: 2 times
Dream Kudos: 675
My Contributions
I am refering to an actual printer, So is there any other way?
-Thanks
User is offlineProfile CardPM
+Quote Post

MorphiusFaydal
RE: Printing Files
5 Sep, 2007 - 02:30 PM
Post #5

D.I.C Lover
Group Icon

Joined: 12 May, 2005
Posts: 1,104



Thanked: 8 times
Expert In: Hardware, Networking

My Contributions
You'd have to interface with the printer controller on the operating system... CUPS, probably, for most modern Linux and (maybe) BSD systems (including OS X... although that probably has it's own printing system)

Try googleing for tuts on printing and see what turns up
User is offlineProfile CardPM
+Quote Post

aj32
RE: Printing Files
5 Sep, 2007 - 04:01 PM
Post #6

D.I.C Addict
Group Icon

Joined: 30 Aug, 2007
Posts: 577



Thanked: 2 times
Dream Kudos: 675
My Contributions
Ok, I search for one later when I get a chance, i'm in a hurry right now! -Let you know what I find.

-Thanks
User is offlineProfile CardPM
+Quote Post

Xing
RE: Printing Files
6 Sep, 2007 - 08:35 AM
Post #7

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
Take a look at
http://www.cprogramming.com/tutorial/lesson10.html
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Printing Files
6 Sep, 2007 - 08:38 AM
Post #8

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,451



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(aj32 @ 5 Sep, 2007 - 03:00 PM) *

I am refering to an actual printer, So is there any other way?
-Thanks

What I did just to cheat, was open the LPT1 port as a file, & then copy data to it. Sure enough, it'll start printing out. Just keep in mind, that you'll need to issue \r as well as \n, in order to get a carriage return.

http://www.dreamincode.net/code/snippet1010.htm

User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 12:56AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month