gen_testfile.c
713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdlib.h>
#include <stdio.h>
#define BLKSZ (16*1024)
int main(int argc, char* argv[])
{
FILE *out=NULL;
int i, blks, j, indx=0;
unsigned char *buf;
if(argc!=3){
printf("args: <outfilename> <outfileBlocks(16KB)>\n");
return 1;
}
blks = atoi(argv[2]);
buf = malloc(BLKSZ);
out = fopen(argv[1], "w");
if(out==NULL)
return 1;
printf("Outputting blocks. Each has all same value:\n");
for(j=0;j<blks;j++){
for(i=0;i<BLKSZ;i++){
buf[i]=(unsigned char)j;
}
printf(" %d,",j);
if(!(j&0xf)) printf("\n");
fwrite(buf,1,BLKSZ,out);
}
free(buf);
fclose(out);
return 0;
}