Write function not using the seekp value
I'm trying to use C++ to write an entry in a specific place in a file so basicly I have ofstream ofs("file.dat", ios::binary | ios::app); ofs.seekp(220, ios::beg); ofs.write((char *)&i, sizeof(i)); But no matter what I do it always write at the end of the file. I suppose this is related to iso::app because according to the documentation app (append) Set the stream's position indicator to the end of the stream before each output operation But if I use ate or nothing it always erases the content of the file. Any help would be great :) Yes, it's the ios::app that's causing this behaviour. Replace