I think that "the Book" wants to show you something more than just opening and reading something from a file.
This should work:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#inlcude<cstdio>
#include<iostream>
usingnamespace std;
FILE *file;
int main()
{ char str[10000];
file=fopen("textfile.txt", "r+");
while(!feof(file)) //this checks the end of the file - (pointer)
{ fgets(str, 10000, file);
cout<<str<<" ";
}
fclose(file);
return 0;
}
I think that you want to write the name of the file (or the path) and to open the file with that name. Anyway, the program below opens a text file (named "textfile.txt") and read everything on it untill the eof-pointer. I didn't compile the code but it should work properly.