C++做复制字符串,入参需要的是const c*,我手头的数据是std::string,假设叫str吧,于是我把str.c_str输入进去,结果报了C3867错误。
这是为什么呢?
其实非常简单,此处不应该用str.c_str,而是应该用str.c_str()。根本就没有c_str这个写法,只是ide不报错而已。
这种小细节还是要注意。
C++做复制字符串,入参需要的是const c*,我手头的数据是std::string,假设叫str吧,于是我把str.c_str输入进去,结果报了C3867错误。
这是为什么呢?
其实非常简单,此处不应该用str.c_str,而是应该用str.c_str()。根本就没有c_str这个写法,只是ide不报错而已。
这种小细节还是要注意。