Sizing Up Some Characters
Test your C++ programming skills by solving the given puzzle about array size determination and function parameter behavior.
We'll cover the following
Puzzle code
Carefully read the code given below:
#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);}
Your task: Guess the output
Try to guess the output of the above code. Attempt the following test to assess your understanding.
Let’s discuss this code and output together in the next lesson.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.