Reputation: 191
I am learning C and I had a question. I am trying to append a string into a file. However, every time a string is appended it has to be on the next line (Sort of like println instead of print).
I cannot make the function append on the next line. Instead, it just keeps appending on the same line. How do I do this?
void FileWriter(char *cmmd)
{
FILE *fp;
fp = fopen("xxx.txt", "a");
fprintf(fp, "%s", cmmd);
fclose(fp);
}
Thanks!
Upvotes: 1
Views: 46
Reputation: 191
I'm sorry I'm dumb. I put a \n after %s and it worked. Maybe there is a better way?
Upvotes: 0