I need to write two variables to a text file with a space in between them, what I want my text file to look like:
log.txt
www.google.com feb17202101
www.yahoo.com feb17202102
www.xyz.com feb17202103
The domain name and dates are stored in two char arrays.
My code
FILE *fp;
fp = fopen("log.txt", "w+");
if(fp == NULL)
{
printf("Could not open file 31");
exit(0);
}
fprintf(fp,"%s %s\n",domainName, fileName);
(DomainName and fileName are two separate char arrays) I was hoping this would print both my variables with a space in between them and go onto the next line so when my function needs to write to the text file again, it will be on a fresh line.
Instead my text file looks like
www.google.com
022321224825
This seems like it should be the easiest part of my program but it's one of those days where I spent all day coding and now my brain feels fried haha. I can't figure out how to format it properly. If someone could help me out, I would appreciate it!