Are all char arrays automatically null-terminated?

前端 未结 3 1836
粉色の甜心
粉色の甜心 2020-12-09 05:26

Probably I\'m just too dump for googling, but I always thought char arrays get only null terminated by an literal initialization (char x[]=\"asdf\";) and got a

3条回答
  •  清歌不尽
    2020-12-09 05:46

    If t is an array of size 2, then the last case is t[2 - 1] = t[1] and not 2. t[2] is out of bounds.

提交回复
热议问题