epcim
3/3/2016 - 11:37 AM

Make a big file with random content

Make a big file with random content

//gcc -std=gnu99 -o makeMeBigger makebig.c

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main() {

	int32_t buf[256]; // Block size.
	for (int i = 0; i < 256; ++i)
	{
	  buf[i] = rand(); // random to be non-compressible.
	}
	FILE* file = fopen("/PATH/TO/YOUR/BigFile", "wb");
	int blocksToWrite = 1024 * 1024 * 1024; // 1 TB
	for (int i=0; i<blocksToWrite; ++i)
	{
	     fwrite(buf, sizeof(int32_t), 256, file);
	}
}