String initialization with and without explicit trailing terminator

前端 未结 4 1374
梦谈多话
梦谈多话 2020-12-31 05:29

What is the difference between

char str1[32] = \"\\0\";

and

char str2[32] = \"\";
4条回答
  •  我在风中等你
    2020-12-31 06:01

    Unless I'm mistaken, the first will initialize 2 chars to 0 (the '\0' and the terminator that's always there, and leave the rest untouched, and the last will initialize only 1 char (the terminator).

提交回复
热议问题