| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1809 人关注过本帖
标题:[求助]字符串怎么声明
取消只看楼主 加入收藏
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
 问题点数:0 回复次数:6 
[求助]字符串怎么声明

请问各位
声明字符串怎么声明啊
我 写的老是报错啊
#include <iostream.h>
#include <string.h>
using namespace std;


int main()
{
string name="zhong";
cout<<string<<endl;
return 0;
}
-------------------Configuration: string - Win32 Debug--------------------
Compiling...
string.cpp
E:\vc++\add\string\string.cpp(7) : error C2065: 'string' : undeclared identifier
E:\vc++\add\string\string.cpp(7) : error C2146: syntax error : missing ';' before identifier 'name'
E:\vc++\add\string\string.cpp(7) : error C2065: 'name' : undeclared identifier
E:\vc++\add\string\string.cpp(7) : error C2440: '=' : cannot convert from 'char [6]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.

string.exe - 1 error(s), 0 warning(s)

请问这是怎么回事哦

搜索更多相关主题的帖子: string 声明 字符 cpp 
2007-07-23 09:44
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 
哎,在线等待吧
想尽快把问题解决了
2007-07-23 09:45
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 
我改了,还是那个错误啊 !
怎么办
是不是编译器的问题啊
2007-07-23 10:02
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 

现在又有新的问题了


#include <iostream.h>
#include <string>
using namespace std;


int main()
{
string name="zhong";
cout<<name<<endl;
return 0;
}

--------------------Configuration: string - Win32 Debug--------------------
Compiling...
string.cpp
E:\vc++\add\string\string.cpp(9) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversio
n)
执行 cl.exe 时出错.

string.exe - 1 error(s), 0 warning(s)

2007-07-23 10:04
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 
呵呵
通过了
为什么这样改啊
请指教
2007-07-23 10:20
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 
呵呵 ,我是新手
非常感谢!
可以加我QQ吗?
790405023--黄牛程序员
2007-07-23 10:35
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 

呵呵
我 没收到你的信息哦
我有问题还要多多请教你呢

2007-07-23 18:15
快速回复:[求助]字符串怎么声明
数据加载中...
 
   



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

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