Join waitlist
C++Community question

printf("%d", sizeof('a')) output?

Asked by aman khan 29 days ago 2 answers 3 votes

quiz said 4 but char is 1 byte?

2 answers

Karthik Rajan29 days agoMost voted4

in C, 'a' is an int constant, so sizeof('a') is sizeof(int), usually 4. in C++ it's a char, so 1. check which language the question was in

aman khan29 days ago

it was C. ok

Related questions

Go deeper

Want the full explanation, not just an answer?

Structured lessons on DSA, core CS, Java and interview skills, each ending in a quiz so you know it stuck.