Hello, I am new to this forum and happy to be a new member and eager to learn from you guys! I have this code dealing with C++ stream classes and I can't seem to get it to work. It seems simple enough, I need to read contents of a file and list them in the output. Could someone please advise how I can get this to compile and run correctly on VC++.net? I have also tried this on Dev-C++ compiler and it will not work for me. I know something with the source code is wrong. Could it be that I am using "old" style and trying to use fstream.h ?
Thanks in advance!!Code:#include <iostream> #include <fstream.h> using namespace std; void main () { char ch; fstream file; char filename[20]; cout << "Enter the name of the file: " <<flush; cin >> filename; file.open(filename, ios::in); file.unsetf(ios::skipws); while (1) { file >> ch; if (file.fail()) break; cout << ch; } file.close(); }