I am having massive problems reading notepad files in C++. I've tried like 5 different methods and none of them work. I want to be able to pull a string from a notepad file--thoughts?
If compilers matter, xCode, which might be why I'm having problems. I recall having done this several times before on my old XP, where I used visual studio. Anyhoo...
Basically, I'm trying to compile data, and the best way for me to do this is to make a program that goes in and .find()s a bunch of numbers. But if I can't pull the data out into a string in my program, that plan sort of dies.
Code:
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("test.txt");
if (myfile.is_open()) {
string file = "";
while (myfile.good()) {
getline (myfile,line);
file += line;
}
myfile.close();
} else {
cout << "Unable to open file";
}
return 0;
}
_________________
Liam wrote:
Rise my minions, VOTE FERR3T #1 FOR HEAD MOD!!
Simmen wrote:
How are you not a admin Hal?..