I am pretty new to C Programming and I'm having problems with my code. My program opens a .txt file and stores the data inside it in a string. After that, the data stored in a string is copied into another .txt file.
FILE * fp = fopen("New.txt", "a");
FILE * fp2 = fopen("File.txt", "r");
while(fgets(str, 100, fp2) != NULL) {
fputs(str, fp);
}
fclose(fp);
fclose(fp2);
Now my problem here is, I want to store the strings in a single line, but my program always goes to the next line. For example, I want the data to be:
One Two Three
What my code does:
One
Two
Three
Can you help me? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire