Closed dmalan closed 5 years ago
Yes on all counts. Each of those lines is necessary to allow the printf-like arguments to get_*.
@crossroads1112 can you remind me what role https://github.com/cs50/libcs50/blob/2019/src/cs50.h#L101 plays specifically? Is that trick necessary anymore, if we require now that get_string
have at least one argument (the prompt) anyway? It's really just the second, third, etc. arguments that are optional now?
That trick was to allow get_string to be called internally by get_int etc. There are two contexts in which get_string can be called: directly, in which it gets its arguments variadic arguments the standard way, or internally by get_int et al in which case their variadic arguments have already been stored in a va_list. This first parameter disambiguates between these two cases. When getstring is called by students, the first parameter is NULL whereas get* pass their own va_list as its first parameter
Ah, right, thanks!
CC @kzidane