I'm trying to generate a text file that has 50 lines, each line consisting of 50 spaces. However, every few lines, 9 or 10 extra bytes gets added to the file.
#include <iostream>
#include <fstream>
using namespace std;
void InitializeCanvas() {
ofstream file("paint.txt");
int b = 0;
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 50; j++) {
file << " ";
}
file << "\r\n";
//these lines show where the pointer is and where it should be
b += 52;
int pointer = file.tellp();
int difference = pointer - b;
cout << pointer << " (" << (difference) << ")" << endl;
}
file.close();
}
int main() {
InitializeCanvas();
return 0;
}
On line 9, 9 extra bytes are added. On lines 19, there are 19 extra bytes. Same for 29, 39, and 49. No extra bytes are added except for on those lines. What could be causing that? This code was compiled using CodeBlocks 13.12.