Here's an example that might help you out:
Code:
#include <string.h>
#include <stdio.h>
int main(void)
{
FILE *stream;
char msg[] = "this is a test";
char buf[20];
if ((stream = fopen("DUMMY.FIL", "w+"))
== NULL)
{
fprintf(stderr, "Cannot open output file.\n");
return 1;
}
/* write some data to the file */
fwrite(msg, strlen(msg)+1, 1, stream);
/* seek to the beginning of the file */
fseek(stream, SEEK_SET, 0);
/* read the data and display it */
fread(buf, strlen(msg)+1, 1, stream);
printf("%s\n", buf);
fclose(stream);
return 0;
}
A while loop could be used nicely to read in your blocks of data. Every block that you read in, you turn right around and write it out, again in binary format, with fwrite(). Then get another block of data with fread()
The number 1 just before "stream" is the number of blocks (of the size you have specified), that fread will attempt to read. On EOF (End Of File), fread() will return a number less than the one you have specified (zero I expect).
So the number 1 is the key to using fread() in a while loop:
Code:
while((fread(all the normal stuff here)) > 0) {
write out your block of data, in here.
}
I'm no expert on binary file copying, but the above looks like a good place to start for your loop.
Study these details and see how buff, msg, the +1, and stream, all work together.
Edit: You don't have Turbo C, so get rid of the #include <conio.h>. You won't need it anywhere for this assignment.