找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1724|回复: 2

'string' : undeclared identifier,这是怎么回事?

[复制链接]
发表于 2009-11-2 04:17:43 | 显示全部楼层 |阅读模式 IP:江苏扬州
/*编写一个函数,它接受一个指向string对象的引用作为参数,并将该string对象的内容转化成大写,为此可以
使用表6.4描述的函数toupper()。然后编写一个程序,它通过使用一个循环让您能够用不同的输入来测试这个函数
该程序的运行如下:
Enter a string (q to quit):go away
GO AWAY
Enter a string (q to quit):good grief!
GOOD GRIEF!
Enter a string (q to quit):q
Bye.
*/
#include <iostream>
#include <string>
#include <cctype>
void convert(string &str);
int main()
{
using namespace std;
string str1;
cout<<"Enter a string(q to quit):\n";
cin>>str1;
if (str1!='q')
{
while (str1)
{
convert(str1);
cout<<str1;
cout<<"Enter a string(q to quit):\n";
cin>>str1;
}
}
else
cout<<"Bye.\n";
return 0;
}
void convert(string &str)
{
using namespace std;
int limit=strlen(str);
for(int i=0;i<limit;i++)
{
if (isalpha(str[i]))
toupper(str[i]);
}
}
编译的时候总是说:
error C2065: 'string' : undeclared identifier
error C2065: 'str' : undeclared identifier
error C2182: 'convert' : illegal use of type 'void'
我感觉我在使用之前有定义啊,到底是哪里出了问题呢?
发表于 2009-11-2 04:17:47 | 显示全部楼层 IP:江苏扬州
#include &lt;cstring&gt;
回复

使用道具 举报

发表于 2009-11-2 04:17:51 | 显示全部楼层 IP:江苏扬州
我试过呢,还是一样的问题啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 01:26 , Processed in 0.330299 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表