Im trying to use a pointer to point to my desired input stream depending on user decision. This is what ive got so far.
string fileName = "test.txt";
ifsteam = myFile;
myFile.open(fileName.c_str(), ifstream::in);
istream * myStream;
if (file_mode) {
myStream = &myFile;
} else {
myStream = &cin;
}
string out;
while (myStream >> out) {
cout << out << endl;
}
The problem seems to be that nothing is streaming from myStream to out.
Any help would be greatly appreciated.