I need to write C++ code that will open a binary file and will write 5 MB of '1' in to it.
Currently my code is:
#define BYTES_BUFFER_SIZE_5MB (1024*1024*5)
static char buffer[BYTES_BUFFER_SIZE_5MB];
memset(buffer, 0xff, BYTES_BUFFER_SIZE_5MB);
ofstream myFile ("data.bin", ios::out | ios::binary);
myFile.write(buffer, BYTES_BUFFER_SIZE_5MB);
Is there a memset
-like method for writing to a file, so I can avoid having a buffer?