+ 1

For_loop doubt

https://code.sololearn.com/ctbxIKrtLzlF hi friends , here the expected output is eight nine even odd but with this code ....I am getting output as eightnine nine even odd how can i get ....expected output....?

15th Jun 2019, 5:50 AM
malepu rakesh
malepu rakesh - avatar
1 Odpowiedź
+ 3
In C, strings end in a '\0' (NUL) character. Because your declaration is x[...][5], the terminating NUL character of "eight" can not be stored, so printf does not know when eight ends. Because "eight" and "nine" are stored sequentially in memory, printf continues searching, until it finds nine's '\0'. To solve this bug, declare it as char x[...][6]
15th Jun 2019, 6:12 AM
Vlad Serbu
Vlad Serbu - avatar