错误:
#include<ioStream>
using namespace std;
int main(){
//1 C风格字符串
char str[] = "asdf";
cout << str << endl;
//2 C++风格字符串
string str2 = "zxcvb";
cout << str2 << endl;
system("pause");
return 0;
}
原因:
程序中使用了string,但是头文件没有加上#include<string>
解决:
#include<ioStream>
//用c++风格的字符串包含这个头文件
#include<string>
using namespace std;
int main(){
//1 C风格字符串
char str[] = "asdf";
cout << str << endl;
//2 C++风格字符串
string str2 = "zxcvb";
cout << str2 << endl;
system("pause");
return 0;
}