Puzzle 21 | Sizing 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 | |
---|---|
Try to guess what the output is before moving to the next page. |
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.