naseeam
asked on
printf can not be a macro defined in terms of fprintf ?
Please explain following sentence from 'C' language book:
"Note, though, that unlike getchar and fgetc, printf can not be a macro defined in terms of fprintf, because macros can not have a variable number of arguments."
Please provide example of how there will be variable number of arguments if printf is a macro defined in terms of fprintf ?
"Note, though, that unlike getchar and fgetc, printf can not be a macro defined in terms of fprintf, because macros can not have a variable number of arguments."
Please provide example of how there will be variable number of arguments if printf is a macro defined in terms of fprintf ?
ASKER
Please provide example of printf being a macro defined in terms of fprintf. Then, explain why it can't be done.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great explanation with great examples.
printf("Good morning, %s, did you know that %d + %d = %d?",name,5,5,10);
printf("Good morning, %s",name);
Here printf has 4 args (5 including the string) in the first, and 1 or 2 in the second. It is saying you can't do this in the macro because it won't allow variable args..I think.