Hello once again!
I am working on a program that is supposed to do I/O file streaming. I dont know if I can properly explain how its supposed to work but I have found the error on my code, I just dont know WHY the error is happening? If you look in the while loop, count changes values like it should, but MOVE and TIP doesnt. Count starts at value 2. So move is 108. Then count becomes 4, but move stays at 108?
tring rec;
fstream myfile("File.txt", ios::in | ios::out);
myfile.seekg(myfile.tellg(), ios::beg);
myfile.seekp(51, ios::beg);
int count = myfile.get();
count -= 48;
if (myfile.is_open())
{
while (getline(myfile, rec))
{
int move = count * 54;
int tip = move + 51;
myfile.seekp(move, ios::beg);
char line[54];
while (myfile.getline(line, 54)) {
cout << line << endl;
break;
}
myfile.seekp(tip, ios::beg);
int count = myfile.get();
count -= 48;
if (count == -1)
{
break;
}
}
myfile.close();
}
The lines of code im getting errors on is
1 2
int move = count * 54;
int tip = move + 51;
Move wont change its value? It stays 108, causing this infinite while loop. Does anyone see an error in my code to cause move to not change values like count does?
I seem to be struggling with I/O File streaming :(