Braces around string literal in char array declaration valid? (e.g. char s[] = {“Hello World”})

前端 未结 6 542
我在风中等你
我在风中等你 2020-12-03 06:32

By accident I found that the line char s[] = {\"Hello World\"}; is properly compiled and seems to be treated the same as char s[] = \"Hello World\";

6条回答
  •  失恋的感觉
    2020-12-03 07:01

    Any variable in (int, char, etc.) is just an array of length 1.

    char s = {0};
    

    works as well.

提交回复
热议问题