In the "myPrintf" function below (which runs correctly when called), I don't understand how it takes a const char * (pointer) as a parameter but then drops the star (*) in the function definition. Isn't that a change from pointer to a memory address??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[code]
#include <stdarg.h>
int myPrintf(constchar *s, ...)
{
va_list arguments;
va_start (arguments, s);
int c = 0;
c = vprintf(s, arguments);
return c;
}
int main()
{
myPrintf("Hello %d\n", 1234);
return 0;
}
's' is a name of variable that is a pointer. The va_start and vprintf look like functions, and functions can take pointer as parameter (myPrintf is an example of that).
If you would write *s in statement, you would be calling the dereference operator. Then you would not pass a pointer, but the value pointed to by the pointer.