I'm not great with C++ myself, especially when it involves the console, but this is how I'd do what you're trying to do:
#include <iostream.h>
#include <stdio.h>
void openfile();
int main()
{
openfile();
return 0;
}
void openfile()
{
char fileopen[1024] = "";
char filedata;
FILE* aFile;
cout << "Open File >>";
cin >> fileopen;
cout << "File = " << fileopen << "\n";
aFile = fopen(fileopen, "r");
if(!aFile)
{
cout << "Error!";
return;
}
while(!feof(aFile))
{
filedata = getc(aFile);
cout << filedata;
}
cout << endl;
fclose(aFile);
}
Hope it helps.
We rode on the winds of the rising storm, we ran to the sounds of the thunder.
We danced among the ligtning bolts, and tore the world asunder.