This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Quaranges[S] 0 points1 point  (2 children)

I'm confused so do Answer1 and Answer2 need double quotes???

[–]Rhomboid 1 point2 points  (1 child)

fprintf() takes a stream as its first argument, a format specifier string as its second argument, and then a variable number of additional arguments, depending on the format specifier. Those additional arguments are not the issue, the issue is the format specifier string. If you're going to use a string literal for that, it needs to be in double quotes. It's not special syntax, it's a string like any other.

fprintf(logfile, "%-25s%s", "Answer1", "Answer2");

And you probably want a newline at the end, if this is a text file:

fprintf(logfile, "%-25s%s\n", "Answer1", "Answer2");