[c++] Why the following code is working ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[c++] Why the following code is working ?

why the code is working fine ? goto: https://code.sololearn.com/cA9a25a96A09

27th Apr 2021, 5:04 AM
𝖆𝖙.𝖚𝕷
𝖆𝖙.𝖚𝕷 - avatar
3 Answers
+ 3
https://stackoverflow.com/questions/23843760/how-is-char-array-an-oversize-when-filled-by-cin-geta-size
27th Apr 2021, 5:18 AM
Rohit Kh
Rohit Kh - avatar
+ 2
Your program is showing an undefined behaviour. C++ doesn't specify what to do when a program tries to access values outside the limit of arrays, so the behaviour of the program can't be determined there.
27th Apr 2021, 5:27 AM
Arsenic
Arsenic - avatar
+ 1
5 elements of 5 bytes each 23 is just 1 element out of 5 The one-dimensional array can hold 5 elements.😎
29th Apr 2021, 3:37 AM
Sanjay Kamath
Sanjay Kamath - avatar