char* vs const char* as a parameter

后端 未结 5 538
逝去的感伤
逝去的感伤 2021-01-30 05:10

There are many times that I get compile errors when I use char* instead of const char*. So, I am not sure the actual difference, the syntax and the com

5条回答
  •  执念已碎
    2021-01-30 05:50

    I always try to define parameters with const char* not char* because converting from std::string to conts char* is easy by .c_str() method. However converting std::string to char* is not that easy.

提交回复
热议问题