the reason im using fscanf and fprintf is cos i need to do some mathematical manipulation with each and every number in the binary file, which are in unsigned char (each number runs anywhere from 0-255). but before all those manipulations come in, i wanted to just try copying the values into new files. Actually I thought a much simpler prog would suffice for copying files:
Code:
FILE *fp2, *fp3, *fpr2, *fpr3;
fp2 = fopen("C:\\band2", "rb");
fp3 = fopen("C:\\band3", "rb");
fpr2 = fopen("C:\\r2", "wb");
fpr3 = fopen("C:\\r3", "wb");
long int i, size = 1249820;;
unsigned char a2[size], a3[size];
for(i=0, i<size, i++){
fscanf(fp2, "%c", &a2[i];
fscanf(fp3, "%c", &a3[i];
fprintf(fpr2, "%c", a2[i];
fprintf(fpr3, "%c", a3[i];
}
//then fclose all files
it crashes when i run it, but there are no compilation errors. the funny thing is, when i change 'size' to a smaller number, say 10,000, it runs perfectly. i was told this might be due to some differences in the 'stack' and 'heap' memory types in the computer, which is why im now using malloc instead.