It is hard for me, because I am used to write(b,f); function from Pascal and here is fread() and there are four arguments there.
Here is my attempt:
/* not finished */
#include<stdio.h>
#include<math.h>
main()
{
FILE *f1;
FILE *f2;
char s[20];
unsigned char b;
printf("This program copies a given file.\n\n");
printf("Enter file name:\n\n");
scanf("%s",&s);
printf("Processing..\n\n");
f1=fopen(s,"rb"); /*Open the file Input*/
f2=fopen("output.out","wb"); /*Open the file Output*/
b=5;
while( b != EOF ){
fread(b,1,1,f1);
fwrite(b,1,1,f2);
}
fclose(f1); /*close the file input*/
fclose(f2); /*close the file output*/
printf("Done. File output.out created.");
getch();
}
Thank you for help.
Edited by nerio, 26 November 2010 - 03:35 PM.


Sign In
Create Account


Back to top









