通过C程序将一个文件内容拷贝到另外一个文件,代码,把程序一拷进CSDN编辑器就变得缩进没了,真是郁闷:

/*Global inclusions*/
#include<stdio.h>
#include<stdafx.h>
#include<string.h>
#include<conio.h>
/*Gloabal function definition*/
void CharReadWrite(FILE *fl1, FILE *fl2);
/*Main function*/

void main()
{
/*Define two file pointers*/

FILE *fl1, *fl2;
/*Initialize files router*/

char namefl1[] ="C:\\Documents\\Demo1.txt";
char namefl2[] ="C:\\Documents\\Demo2.txt";
/*Open file1 in reading modern*/

fl1 = fopen( namefl1,"r" );
/*Open file2 in writing modern*/

fl2 = fopen( namefl2,"w" );
/*Make sure above two steps perform correctly*/

if (fl1 == NULL)
{
if(fl2 == NULL)
{
printf("Can't open file %s.\n", namefl2);
}
else

{
printf("Can't open file %s.\n", namefl1);
}
}
else

{
/*Copy content*/

CharReadWrite(fl1, fl2);
/*Close file stream*/

fclose(fl1);
fclose(fl2);
getch();
}
}
void CharReadWrite(FILE *fl1, FILE *fl2)
{
int c;
while((c = fgetc(fl1)) != EOF)
{
fputc(c, fl2);
putchar(c);
}
}