Hey!
This time, I'm trying to collect the text (ALL text) from a text file, and put it in a string that I can print out later. Here's what I've come up with:
Hmm... doesn't seem to work right.Code:#include <iostream.h> #include <stdio.h> #include <fstream.h> using namespace std; string InfoCollectDataHolder; class ParseText { public: ParseText(); ~ParseText(); void Parse(); protected: string InfoCollectDataHolder; }; ParseText::ParseText() { } ParseText::~ParseText() { } void ParseText::Parse() { ifstream FileToParse("InfoCollect.txt"); while (FileToParse) { getline (FileToParse, InfoCollectDataHolder); } FileToParse.close(); } int main() { ParseText ParseExample; ParseExample.Parse(); cout<<InfoCollectDataHolder; cin.get(); }
Can somebody show me the err's of my ways?
Thanks for your help!
FlyingIsFun1217