What does this do?

L

LL

#include <stdio.h>

int main() {
enum {
TEST1, TEST2
} stuff_to_print;

printf(TEST1, TEST2); // what does this do? Gives no output.
}
 
K

Keith Thompson

LL said:
#include <stdio.h>

int main() {
enum {
TEST1, TEST2
} stuff_to_print;

printf(TEST1, TEST2); // what does this do? Gives no output.
}

It invokes undefined behavior.

Where did you find that horrid piece of code?
 
C

CBFalconer

Keith said:
It invokes undefined behavior.

Where did you find that horrid piece of code?

Is it undefined? Is it equivalent to "printf(0, 1);"? Is that
equivalent to "printf(NULL, 1);"? Is that undefined behaviour?
 
B

Ben Pfaff

CBFalconer said:
Is it undefined? Is it equivalent to "printf(0, 1);"? Is that
equivalent to "printf(NULL, 1);"? Is that undefined behaviour?

Yes, yes, yes, and yes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top