how to initialize a char array?

前端 未结 8 1825
名媛妹妹
名媛妹妹 2020-12-14 14:39
char * msg = new char[65546];

want to initialize to 0 for all of them. what is the best way to do this in C++?

8条回答
  •  离开以前
    2020-12-14 15:05

    Absent a really good reason to do otherwise, I'd probably use:

    std::vector msg(65546, '\0');
    

提交回复
热议问题