I am trying to take a a file of fixed size and use seekp to jump to a particular spot in the file, write around 100 bytes or so but only to that part of the file while still keeping the size of the total file the same and not losing the other data. As of right now it is adjusting the total size of the file to the size of the buffer but I dont want that to happen. Heres what I have so far, any help is appreciated.

int r = 2;
int size = 99;
char * buffer = new char(size);
fstream out;
out.open("C:\\Database\\2.bin", ios::out|ios::binary);
out.write(buffer, size+1);

Not sure I quite understand. Let's say the file contains "ABCEFGH". Now seek to there the 'E' appears and write "KLM". What result do you want
3) something else

lets say I have a 1000 byte file and bytes 900-1000 are filled with data and I want to write to bytes 400-500, so I do that but everytime I do it resets the file size to 500 bytes killing the data farther in the file. I want to make it so it will write the new data to bytes 400-500 and keep the data at bytes 900-1000 while keeping the file size constant and not adjusting it therefore just updating part of the file with new data.