Hi I am trying to create a program in which I want to store the words which I have from one text file to another text file but I do not want to delete the elements in which I have to the second file .
The problem is that when I ran my code and it overwrites elements from one file to another instead of "passing" elements from one file to another .
How can I fix this? Is it better to store to a third empty file?
Excuse for my english
text files :
con1 (github.com)
con2 (github.com)
Code:
#include<stdio.h>
#include<stdlib.h>
int main ()
{
FILE *fp1, *fp2;
char arr[10][100]={"aaaa","bbbbbbdbdhcdc","bjjbkgfjnfjbfj","vfvmvldvddkv"};
fp1=fopen("con1.txt","w");
int i=0;
for(i=0 ; i<4 ; i++)
{
fputs(arr[i],fp1);
fputs(" ",fp1);
}
fclose(fp1);
fp1=fopen("con1.txt","r");
fp2=fopen("con2.txt","w");
fseek(fp2,0,SEEK_END);
for(i=0 ; i < 4 ; i++)
{
fputs(" ",fp2);
fputs(arr[i],fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}