//main.cpp
//~#include "iostream.h"
#include "string.h"using namespace std;int main()
{
string user_name;
cin >> user_name;
cout << end
<< user_name;
return 0;
}编译时出现如下错误:
--------------------Configuration: CIN - Win32 Debug--------------------
Compiling...
CIN.CPP
F:\源代码\c\CIN.CPP(7) : error C2871: 'std' : does not exist or is not a namespace
F:\源代码\c\CIN.CPP(11) : error C2065: 'string' : undeclared identifier
F:\源代码\c\CIN.CPP(11) : error C2146: syntax error : missing ';' before identifier 'user_name'
F:\源代码\c\CIN.CPP(11) : error C2065: 'user_name' : undeclared identifier
F:\源代码\c\CIN.CPP(14) : error C2065: 'end' : undeclared identifier
Error executing cl.exe.CIN.exe - 5 error(s), 0 warning(s)
//~#include "iostream.h"
#include "string.h"using namespace std;int main()
{
string user_name;
cin >> user_name;
cout << end
<< user_name;
return 0;
}编译时出现如下错误:
--------------------Configuration: CIN - Win32 Debug--------------------
Compiling...
CIN.CPP
F:\源代码\c\CIN.CPP(7) : error C2871: 'std' : does not exist or is not a namespace
F:\源代码\c\CIN.CPP(11) : error C2065: 'string' : undeclared identifier
F:\源代码\c\CIN.CPP(11) : error C2146: syntax error : missing ';' before identifier 'user_name'
F:\源代码\c\CIN.CPP(11) : error C2065: 'user_name' : undeclared identifier
F:\源代码\c\CIN.CPP(14) : error C2065: 'end' : undeclared identifier
Error executing cl.exe.CIN.exe - 5 error(s), 0 warning(s)
解决方案 »
- 今天看了点法律,发现网吧真的有点悲剧。。。
- 我学了C++现在在看WINDOWS程序设计这本书看不懂
- 使用CSplitterWnd分裂窗口,如何使分裂后的两个窗口,随着主窗体的大小的变化而改变尺寸。
- 一个内存管理的问题
- 内网穿透~神奇的SendLink!能够在子网机器上远程在出口计算机映射一个端口,以使子网外IP能访问子网机器。有谁知其端口映射的原理?
- delete 问题!急!!!
- 如何遍历ini文件里某一Section下所有项?(急,谢谢)
- SkinMagic Toolkit V1.7b1发布了,做界面简单多了
- win32程序中可否调用数据库?
- 怎么画象调色版对话框里那样的色图??????????????
- 申请基础版斑竹,希望大家支持!
- 下载工具Netants或FlashGet有什么优点?
#include "iostream"
#include "string"using namespace std;int main()
{
string user_name;
cin >> user_name;
cout << endl
<< user_name;
return 0;
}
//~#include <iostream>
#include <string>using namespace std;int main()
{
string user_name;
cin >> user_name;
cout << endl<< user_name <<endl;
return 0;
}
//~#include "iostream"
#include "string"
using namespace std;int main()
{
string user_name;
cin >> user_name;
cout << endl
<< user_name;
return 0;}
一般情况下加不加.h是一模一样的,但是iostream就偏有这么个古怪的个性。
这样试一下也许会好一些
//main.cpp
//~#include "iostream.h"
#include "string"using namespace std;int main()
{
string user_name;
cin >> user_name;
cout << endl<< user_name;
return 0;
}
"string.h"改为"string"
另外最好在它前面加上#pragma warning (disable : 4786)
否则编译会出一堆warning,虽然不影响使用,但看着碍眼