您的位置:首页 > 编程语言 > C语言/C++

C++ std::string和C字符串之间的问题

2016-04-22 16:00 316 查看
今天写的代码遇到了这个问题,这里记录一下,有时间整理:

#include <string>
#include <iostream>
#include <stdlib.h>

int main(){

//std::string str;
std::string str("");

if (str.c_str() == "")
std::cout << "haha" << std::endl;
else
std::cout << "wuwu" << std::endl;

system("pause");
return 0;
}


代码的输出是“wuwu”,也就是说不相等。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: