C++ strings: [] vs. *

后端 未结 6 1198
走了就别回头了
走了就别回头了 2020-12-02 09:22

Been thinking, what\'s the difference between declaring a variable with [] or * ? The way I see it:

char *str = new char[100];
char str2[] = \"Hi world!\";
<         


        
6条回答
  •  一整个雨季
    2020-12-02 09:41

    Please also take a look at the http://c-faq.com/aryptr/aryptr2.html The C-FAQ might prove to be an interesting read in itself.

提交回复
热议问题