program crashes when copying binary file
Hi,
I am trying to copy a binary file (band2) using the following program:
------------------
Code:
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *fp2, *fpr2;
fp2 = fopen("C:\\band2", "rb");
fpr2 = fopen("C:\\r2", "wb");
long int i, size = 1249820;
unsigned char *b2 = malloc (sizeof(*b2));
unsigned char *r2 = malloc (sizeof(*r2));
for(i=0, i<size, i++){
fscanf(fp2, "%c", &b2[i]);
}
for(i=0, i<size, i++){
fprintf(fpr2, "%c", b2[i]);
}
free(b2);
free(b3);
}
---------------------
The program crashes every time I run it. Can someone pls point out to me the mistake?