| CODE |
#include <iostream.h> #include <fstream.h> ifstream fin; //what i use for filein, from fstream.h int main() { fin.open("file.txt"); cout<<fin<<"\n"; fin.close(); system("pause"); } |
| QUOTE |
| #include <iostream>//I removed the ".h" because that gives me a compiler error #include <fstream> #include <string>//So we can use the string var type using namespace std;//You also forgot this. I don't know what it does but each time I leave it aside I get an error ifstream fin; int main() { string str;//I use here a string because as far as I know strings aren't limited in size char file[64];//fin.open needs char and as far as I know can windows path have more than 64 chrarachters cout << "Enter a text file to open" << endl; cin >> file; fin.open(file); fin >> str;//I dont know if "str<<fin" is the same best check it out cout << str << endl; fin.close(); system("pause"); } |
| QUOTE |
| #include <iostream>//I removed the ".h" because that gives me a compiler error |
| QUOTE | ||
|
| QUOTE | ||
|