The parameter last is the name of the last parameter
before the variable argument list, i.e., the last parame-
ter of which the calling function knows the type.
is the second argument to va_start() here. fmt
from my example is a string like "%d %s %p" as you suspected. Anything following the format string in my tprintf() function are variables to be used for substitution. Therefore the fmt
is the last paramater with a known type.
Here's an example usage of my tprintf() function just in case it helps visualize it. It works just like sprintf(), except it returns the formatted string instead of storing it in a buffer you pass to it:
send_msg(player, tprintf("%d apples", num_apples));
send_msg() is of course a hypothetical function that I just came up with for the example
To explain why it needs to know the last argument that isn't part of the substitution variable list, consider reversing the first 2 arguments of sprintf() so the protype looks like: sprintf(char *fmt, char *buffer, ...);
In this case, the second argument to va_start() would be buffer, not fmt.