Archived

This topic is now archived and is closed to further replies.

MPG

infile.get?

Recommended Posts

Here's a short example of how to take a text file and print it out on the console:


#include <fstream.h> //use fstream for textfile input/output


char c1;
ifstream file1;
file1.open("foo.txt", ios::in);
while(file1.get(c1))
cout << c1;


This may or may not include whitespace - I don't remeber.
I'm not sure if its considered good practice to add the ".h" to fstream but its the way I've always done it so there you go.

[edited by - Odoacer on January 24, 2004 9:36:23 PM]

Share this post


Link to post
Share on other sites