Puzzle 21Sizing Up Some Characters

 #include <iostream>
 
 void​ ​serialize​(​char​ characters[])
 {
  std::cout << ​sizeof​(characters) << ​"​​\n​​"​;
 }
 
 int​ ​main​()
 {
 char​ characters[] = {​'a'​, ​'b'​, ​'c'​};
  std::cout << ​sizeof​(characters) << ​"​​\n​​"​;
  std::cout << ​sizeof​(characters) / ​sizeof​(characters[0]) << ​"​​\n​​"​;
  serialize(characters);
 }

Guess the Output

images/aside-icons/important.png

Try to guess what the output is before moving to the next page.

images/hline.png

The program has implementation-defined behavior! But on ...

Get C++ Brain Teasers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.