C++语言,读取第一个文件的时候能不能同时还读取了第二个文件第二个文件的变量怎么进行存储,要将第一个文件的内容和第二个文件的内容对调并且不破坏原来的文件的内容

C++语言,读取第一个文件的时候能不能同时还读取了第二个文件第二个文件的变量怎么进行存储,要将第一个文件的内容和第二个文件的内容对调并且不破坏原来的文件的内容,怎么实现啊,很着急

供参考:

#include <stdio.h>
void file_copy(char *file1, char *file2) // 将文件 file1 内容拷贝到文件 file2
{
    FILE *pf1 ;
    FILE *pf2 ;
    char ch ;

    pf1 = fopen(file1,  "rt");
    if (!pf1){
        printf("file open fail!\n");
        return;
    }
    pf2 = fopen(file2,"wt");
    while(1)
    {
        ch = fgetc(pf1);
        if(feof(pf1))
            break;    //跳出while(1)循环体
        fputc(ch , pf2);
    }
    fclose(pf1);    //关闭文件"file1.c"
    fclose(pf2);    //关闭文件"file2.c"
}
int main()
{
    char file1[] = "student1.txt", file2[] = "student2.txt", tmp[] = "temp.txt";
    file_copy(file1, tmp);
    file_copy(file2, file1);
    file_copy(tmp,   file2);
    remove(tmp);    // 删除临时文件
    return 0;
}

每一个文件是一个变量