How to Initialize char array from a string

后端 未结 11 2004
时光说笑
时光说笑 2020-12-14 09:19

I want to do the following

char a[] = { \'A\', \'B\', \'C\', \'D\'};

But I do not want to write these characters separately. I want somethi

11条回答
  •  一生所求
    2020-12-14 10:09

    const char S[] = "ABCD";
    

    This should work. i use this notation only and it works perfectly fine for me. I don't know how you are using.

提交回复
热议问题