hey every1,
I've got alot of data to write out to file and it's all just 1's and
0's.
It's all stored in 2 dimensional arrays of width 32 and varying
height.
At the moment it's all just integer arrays and the individual 1's and
0's are being written out as integers.
I was just wondering how i cud write them out as actual binary bits
and hence save on the eventual file size.
I've got something like this at the moment....
int main()
{
FILE* dude;
dude = fopen("Bin.dat", "wb");
int swap_a[4][32];
for(int e = 0; e < 4; e++){
for(int d = 0; d < 32; d=d+2){
swap_a[e][d] = 0;
swap_a[e][d+1] = 1;
}
}
for(int j=0; j<4; j++){
for(int d=0; d<32; d++){
fprintf(dude, "%i", swap_a[j][d]);
printf("%i", swap_a[j][d]);
}
fprintf(dude, "\n");
printf("\n");
}
return 1;
}
but all that does is create a file like:
01010101010101010101010101010101
01010101010101010101010101010101
01010101010101010101010101010101
01010101010101010101010101010101
How do i write each 1 or 0 as an actual bit so that they don't take up
as much space in the files as an integer?
Any help wud be well appreciated (sorry for the FILE* usage, just
moved from C)
Thanx,
Rob.