Question 11
Back to Exercise
What is the output of the following program, compiled as C23?
#include <stdio.h>
#define TAG(name, ...) printf("<" name __VA_OPT__(" class='%s'") ">\n" __VA_OPT__(,) __VA_ARGS__)
int main(void) {
TAG("p");
TAG("div", "card");
return 0;
}
- A <p class=''> <div class='card'>
- B <p> <div>
- C <p> <div class='card'> Correct
- D Compilation error
Correct Answer: Option C
__VA_OPT__(x) expands to x only when variable arguments are present, so the first call gets neither the class text nor the comma.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!