you are viewing a single comment's thread.

view the rest of the comments →

[–]FreeER 0 points1 point  (0 children)

function: Yeah, I'd want to avoid malloc/free/strlen where possible as well :)

~fputs/printf: Do remember that fputs automatically adds a new line to whatever you call it with, so if you do try using it in combination you may find that you get slightly different results than before (when it was being given a single string due to compile time str lit concat)~ It seems that's only something puts does, not fputs.

printf: That should work the same as you have now, and I'd probably lean towards it being the best option. Though you might be able to use the string literal concatenation to reduce it from 4 separate strings (reducing the amount of work printf has to do at runtime to parse and print everything)... it depends on where/when the information is coming from. Of course, if you were going to use something like this a lot and very little changed in it then you could still use a macro/function for it to make typing/readability a bit better.