why i cannot debug reading a text file in c++ program code example
Example: how to add and read a file in c++ in visual studio
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int main() {
string input;
fstream file;
char ch;
cout << "Please enter the file name. ";
cin >> input;
file.open(input, ios::in);
if (file) {
file.get(ch);
while (file) {
cout << ch;
file.get(ch);
}
file.close();
}
else {
cout << "Error! " << endl;
}
system("pause");
return 0;
}