Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- int main()
- {
- std::stringstream data;
- int x;
- ifstream inFile;
- inFile.open("C:\\Users\\G. Meier\\Documents\\myfile.txt");
- if (!inFile) {
- cout << "Unable to open file";
- exit(1); // terminate with error
- }
- char c;
- while (inFile.get(c)) {
- data << c;
- }
- inFile.close();
- cout << "data = " << data.str() << endl;
- return cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment