I can't display my whole file, its too complicated/too big to show. I know that may impede things but I think this may be a fundamental issue with these codes. I understand if no one has any ideas/answers with the information I'm providing. I am using this basic list code:
1 2 3 4 5 6 7 8 9 10
|
for (vector<int>::iterator i = List.begin() ; i < List.end() ; i++)
for (vector<int>::iterator j = i+1 ; j < List.end(); j++)
if (*i == *j)
List.erase(j--);
ofstream gfile ("newlist.txt", ios::trunc);
for(vector<int>::iterator i = List.begin(); i != List.end(); i++)
{
gfile << *i << endl;
howmany++;
}
|
as well as:
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
|
std::ifstream afile ("newlist.txt");
std::istream_iterator<int> abeg(afile), aend;
std::set<int> aset(abeg, aend);
std::ifstream gfile ("allfinished.txt");
std::istream_iterator<int> gbeg(gfile), gend;
std::set<int> gset(gbeg, gend);
std::ofstream cfile("pivotfile.txt", ios::trunc);
set_symmetric_difference(aset.begin(), aset.end(),
gset.begin(), gset.end(),
std::ostream_iterator<int>(cfile, "\n"));
ofstream ggfile ("allfinished.txt", ios::trunc);
ggfile << endl;
ggfile.close();
ifstream f1("pivotfile.txt", fstream::binary);
ofstream f2("newlist.txt", fstream::trunc|fstream::binary);
f2 << f1.rdbuf();
f1.close();
f2.close();
ofstream f3("pivotfile.txt", ios::trunc);
f3 << endl;
f3.close();
|
The program loops back over and over again. It runs the first code a few times, and I think the 2nd set of code once before it screws up.
The screw up is that during the List part (which I have confirmed with couts to see where it errors out) when its supposed to be doing "file << *i << endl;" the program errors out and stops responding. This is a console program.
This code works with only 9 digit numbers between 100,000,000 and 999,999,999.
When the program errors out I read the "newlist.txt" and every time (about 5+ times now), the 820th line/number begins with the numbers "82" (as do the few previous lines/numbers, and legitimately so) but then is followed by one of the legitimate 9 digit numbers, but, in that happenstance, the 820th number is no longer a 9 digit number, but rather an 11 digit number. Again, preceded with an "82". This correlation leads me to believe its some glitch in the c++ commands. I even started using the List.clear(); command before each list command to clear it out, but it hasn't solved anything. The newlist.txt typically contains a few thousand numbers. But only number/line 820 has the issue.
I know this may be a shot in the dark, but I'm just hoping for any information which could assist me.