I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?
You can either (1) use those programs as is, (2) look at their source code to find out how they do it and rewrite it in your program, or (3) read the API documentation of your SO and write the code.
A typically acceptable way to do this is to seek to whatever offset you want (past EOF), then write a single byte. That should work on most if not all implementations.
Although I like Disch solution for it's simplicity and OS agnostic approach, I wanted to add to what keskiverto was saying. The way to do this on the command line in Windows is