#define print_int(a) printf("%s : %d\n",#a,(a))
int y=10;
print_int(y)

i am taking a class and have been asked to explain why this is bad... So i guess stringifing #a is the problem. It does work, so why is it dangerous?

Recommended Answers

All 3 Replies

First use code tags. Your code is not Formatted.

#define print_int(a) printf("%s : %d\n",#a,(a))
int y = 10;
print_int(y)

>>i am taking a class and have been asked to explain why this is bad
Beats me. If you find out please post the reason so we can all learn something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.