Location of the text store:
Jack.txt located in: e:\jack.txt
Retchie.txt located in: e:\retchie.txt
Content:
Jack.txt-> "hello! I am Jack. "
Retchie.txt-> "hello! I am Retchie. "
Related code:
Copy Code code as follows:
#include <stdio.h>
int main (void)
{
Char temp1[100];
Char temp2[100];
FILE *p_jack;
FILE *p_retchie;
P_jack = fopen ("E:/jack.txt", "R");
P_retchie = fopen ("E:/retchie.txt", "R");
if (p_jack!= null && p_retchie!= null)
{
Fgets (Temp1, p_jack);
Fgets (Temp2, P_retchie);
}
Fclose (P_jack);
Fclose (P_retchie);
P_jack = fopen ("E:/jack.txt", "w");
P_retchie = fopen ("E:/retchie.txt", "w");
if (p_jack!= null && p_retchie!= null)
{
fprintf (P_jack, "%s", TEMP2);
fprintf (P_retchie, "%s", Temp1);
Fclose (P_jack);
Fclose (P_retchie);
}
return 0;
}
Run Result:
Content:
Jack.txt-> "hello! I am Retchie. "
Retchie.txt-> "hello! I am Jack. "
It's too much trouble to write. Is there a simpler way????