Hello,
In my class I have a method that basically does this:
- Reads in characters from text file (as a string)
- Converts the characters into an integer
- Stores the values into the integer
Here is the code:
bool Loader::Read(string theFile)
{
strRepositry = theFile;
string theData = "";
int i = 0;
int* data2 = new int();
if(!file_exists())
{
return false;
}
ifstream file(strRepositry.c_str());
while(!file.eof())
{
file >> theData;
istringstream convert(theData);
cout << i << endl;
convert >> data2[i++];
}
file.close();
cout << data2[0];
data = data2;
return true;
}
Now this crashes, it's because I'm using i++ but why? And is there a way around it?
Really, really confused.
Thanks :)