"Paul Lemelle" <Pl******@comcast.netwrote in message
news:o2********************************@4ax.com...
>
I am trying to create 10 files of about 2GB each. The problem is that
the first file gets created at the size that I need, but the rest does
not. Please take a look at the below code, and let me know what I am
doing wrong? Thanks.
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE **fp;
char filename[20];
int i;
int count = 0;
int k = 32000;
datasize = 10000 * k;
while (count < datasize)
fprintf(fp[i],"%s","1234567812345678123456781234678\n");
count ++;
Your figures don't add up: 10000*k is 320million. You're then writing
320million lots of 33 characters, or around 10GB in total. And
possibly to the one file, because count is not reset (as already pointed
out).
//fclose(fp[i]);
Why is this commented out?
And, you are appending to the files, so on each run the files will get
bigger.
It's not clear either why you are using malloc for setting up a small array
of file pointers (and having to deal with allocation failures). Or even why
you need an array at all.
--
Bartc