Consider the following code:
#include <stdio.h>
int aaa(char *f, ...)
{
putchar(*f);
return 0;
}
int main(void)
{
aaa("abc");
aaa("%dabc", 3);
aaa(("abc"));
aaa(("%dabc", 3));
return 0;
}
I was wondering why the following lines:
aaa("abc");
aaa("%dabc", 3);
aaa(("abc"));
run without error, but the fourth line (seen below):
aaa(("%dabc", 3));
generates the following errors:
main.c:15:2: warning: passing argument 1 of ‘aaa’ makes pointer from integer without a cast
main.c:3:5: note: expected ‘char *’ but argument is of type `int’
The statement
calls the function
aaawith the argument("%dabc", 3)which returns the value3.Look up the comma operator for more information.