vector<string> arr;
int size = 0;
fstream buffer;
ifstream w;
buffer.open("test.txt");
if (buffer.fail()) {
cout << "invalid";
return;
}
string g;
getline(buffer, g, '\n');
setPlane(g);
while (!buffer.eof()) {
getline(buffer, g, '\n');
size += 1;
arr.resize(size);
arr[size - 1] = g;
}
buffer.close();
w.open("test.txt");
for (int i = 0; i < size; i++) {
w << arr[i] << '\n';
}
w.close();
I'm having an issue where if specifically the ofstream and ifstream are linked to the same file, the program crashes upon running a second a time, but crashes upon running a second time with the updated file.