فایلها
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
FILE *in, *out ;
char ch;
clrscr();
in = fopen("test.dat", "w");
if (!in) {
printf("cannot open file\n");
getch();
exit(1);
}
printf("\n enter characters($ for end):");
do {
ch = getchar();
putc(ch, in);
} while(ch != '$');
fclose(in);
out = fopen("output.dat", "w");
if(!out) {
printf("cannot open out file");
getch();
exit(1);
}
in = fopen("test.dat","r");
if(!in) {
printf("can not open input file");
getch();
exit(1);
}
ch = getc(in);
while(ch != EOF) {
putc(ch, out);
ch = getc(in);
}//end of while
fclose(in);
fclose(out);
printf("\n file test.dat transfered to output.dat.");
getch();
return 0;
}