Q:

How to write at a specific address past end of file

I am working with an fstream object, and I was wondering how is it possible to write something past the end of file, without having to manually fill the space in-between the eof and the desired location with zeroes?
Example :
fstream someFile;
someFile.open("foo.dat", ios :: out | ios :: trunc | ios :: binary); // file is created, and empty
someFile.seekp(100, ios :: beg); // expecting 100 zeroes to be written in file, but nothing happens
someFile.write("yodelay-hee-hoo", 15); // file is still empty, does not work

I've been searching on the issue for about an hour, but I can't find anything much relevant. The only thing I came across is someone that said using .seekp with ios :: end is supposed to fill the gap with zeroes, but I tried and it didn't work for me.
If it helps, I'm on VS2010, native compiling. Thanks a bunch if you can provide a tip.

A:

Short: .seekp() fails if end-of-file was previously reached with .seekg(), thus requiring a call to .clear() beforehand.

Long:
I found that my write operations failed because I first sought a position past the end-of-file with .seekg(), and verified if there was data at that location, by first checking if .eof() returned false and then looking for a non-null character with .peek().
The thing is, even if .seekg() reaches the end-of-file, .eof() seems to always return false until any read/peek/get operation is attempted, and .peek() returns a non-null value (-1) for any position past the end-of-file.
Therefore, the solution was to check for a non-null character before checking if end-of-file was reached, and if past end-of-file, calling .clear() before .seekp(), and it solved everything.

