| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 710 人关注过本帖
标题:[求助]刚学VC就出错,请指点.谢谢
只看楼主 加入收藏
heidong
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-7-20
收藏
 问题点数:0 回复次数:4 
[求助]刚学VC就出错,请指点.谢谢

#include <iostream>
#include <string>
using namespace std;
int main()
{
string username;
cout<<"What is your name?:";
cin>>username;
cout<<"Hello"<<username<<"!"<<endl;
return 0;
}

-------------------Configuration: hello - Win32 Debug--------------------
Compiling...
hello.cpp
e:\heidong\vc++\hello\hello.cpp(3) : error C2871: 'std' : does not exist or is not a namespace
e:\heidong\vc++\hello\hello.cpp(6) : error C2065: 'string' : undeclared identifier
e:\heidong\vc++\hello\hello.cpp(6) : error C2146: syntax error : missing ';' before identifier 'username'
e:\heidong\vc++\hello\hello.cpp(6) : error C2065: 'username' : undeclared identifier
e:\heidong\vc++\hello\hello.cpp(7) : error C2065: 'cout' : undeclared identifier
e:\heidong\vc++\hello\hello.cpp(7) : error C2297: '<<' : illegal, right operand has type 'char [20]'
e:\heidong\vc++\hello\hello.cpp(8) : error C2065: 'cin' : undeclared identifier
e:\heidong\vc++\hello\hello.cpp(8) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
e:\heidong\vc++\hello\hello.cpp(9) : error C2297: '<<' : illegal, right operand has type 'char [6]'
e:\heidong\vc++\hello\hello.cpp(9) : error C2065: 'endl' : undeclared identifier
Error executing cl.exe.

hello.obj - 9 error(s), 1 warning(s)

搜索更多相关主题的帖子: hello cpp username std 
2006-07-20 11:25
飓风
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-7-20
收藏
得分:0 

#include <iostream.h>
#include <string.h>
//using namespace std;
int main()
{
char username[10];
cout<<"What is your name?:";
cin>>username;
cout<<"Hello"<<username<<"!"<<endl;
return 0;
}
不知道using namespace std是什么意思!
所以没改!
这是c++吧,不是vc!


不断的错,总有对的时候……
2006-07-20 15:21
cz522321
Rank: 1
等 级:禁止访问
威 望:2
帖 子:569
专家分:5
注 册:2006-3-13
收藏
得分:0 

这是提示系统你的标准文件库的位置,你学习的还只是C++语言,VC++还又很多东西要学呢!他们是两码事!


2006-07-20 22:37
michaelsoft
Rank: 1
等 级:新手上路
帖 子:75
专家分:0
注 册:2006-7-13
收藏
得分:0 
vc6.0不支持标准c++,用2003吧

2006-07-21 09:30
飓风
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-7-20
收藏
得分:0 
哦 学c++时没见过 using namespace std!
可能是学得比较浅!
呵呵!

不断的错,总有对的时候……
2006-07-21 19:56
快速回复:[求助]刚学VC就出错,请指点.谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011271 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved