Abort R6010
Nov 3, 2013 at 4:25am UTC
Can't understand why this is error is occurring. I'm just trying to split each line from the text file into substrings that I can store into variables for use in other classes/functions but this happens with my second attempt at getting the next substring.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
void initialize(database& db){
// cout.setf(ios::fixed | ios::showpoint);
// cout.precision(2);
string emp[8];
string role, name, num;
ifstream myfile ("Data.txt" );
if (myfile.is_open()){
while (myfile){
for (int i = 0; i < 2; i++){
getline(myfile,emp[i]);
//cout << emp1<<endl;
//int pos = find()
role = emp[i].substr(0,1);
name = emp[i].substr(1,(emp[i].size()-4));
cout<< role << name << endl;
}
// cout << num<<endl;
/* if(role.compare("h")){
getline(myfile,)
}
*/
}
myfile.close();
}
else {
myfile.clear();
cout << "Unable to open file" ;
}
Nov 3, 2013 at 4:59am UTC
So I figured out why it was doing that.
Turns out I had a blank line or a series of spaces a few lines under the data and once I got rid of it no more abort!
Topic archived. No new replies allowed.