I understand that the difference between the printf, fprintf, sprintf etc functions and the vprintf, vfprintf, vsprintf etc functions has to do with how they deal with the function arguments. But how specifically? Is there really any reason to use one over the other? Should I just always use printf as that is a more common thing to see in C, or is there a legitimate reason to pick vprintf instead?
I understand that the difference between the printf , fprintf , sprintf etc functions
Share
printf()and friends are for normal use.vprintf()and friends are for when you want to write your ownprintf()-like function. Say you want to write a function to print errors:You’ll notice that you can’t pass
argstoprintf(), sinceprintf()takes many arguments, rather than oneva_listargument. Thevprintf()functions, however, do take ava_listargument instead of a variable number of arguments, so here is the completed version: