Value in loop wont change? Causing infinite loop

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?

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
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 :(
Last edited on
remove ine on line 21. You are creating a new local variable called count so you never modify the variable created on line 6.
Thank you SO much! I got it fixed!!!!
Topic archived. No new replies allowed.