Plese explain , when I am printing w1[0] why the output is unexpected?

char w[2][3] = { “ab” , “cd”};
cout << w[0] << endl;

	char w1[2][2] = { {'a', 'b'} , {'c', 'd'}};
	cout << w1[0] << endl;

Output

Hello @deepak_four this is the exact code which you are sharing?
this code is not even compilin when i am checking.

It is compiling
Coding Blocks IDE

@deepak_four it was because of the array size.
see this:


Happy Learning!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.