If you are doing it from the console, then you can use
cin
to get input.
You can use a loop of reading chunks and displaying it or adding it to a string to read the contents
#include <iomanip>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main() {
ifstream inFile;
string file;
cout << "Enter a file name:" << endl;
cin >> file;
inFile.open(file.c_str());
if (!inFile.is_open()) {
cout << "Unable to open file";
return -1;
}
char szContents[128];
while (!inFile.eof()) {
memset(szContents, 0, sizeof(szContents));
inFile.read(szContents, sizeof(szContents) - 1);
cout << szContents;
}
inFile.close();
return 0;
}