新手,求助!

Atai-Lu 2007-03-18 08:39:55
#include<iostream>
#include<string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main()
{
string text;
const string separators = ", . \" \n";
const int max_words=1000;
string words[max_words];
string* pwords[max_words];
cout<<endl<<"请输入一串字符,并按#键结束输入:"<<endl;
getline(cin, text, '#');/////////////这里有错误//////////
int start=text.find_first_not_of(separators);
int end = 0;
int word_count=0;
while(start!=string::npos&&word_count<max_words){
end=text.find_first_of(separators,start+1);
if(end==string::npos)
end=text.length();
words[word_count]=text.substr(start,end-start);
pwords[word_count] = &words[word_count];
word_count++;
}
int lowest=0;
for(int j=0;j<word_count-1;j++){
lowest=j;
int i=0;
for(j=j+i;i<word_count;i++)
if(*pwords[i]<*pwords[lowest])
lowest=i;
if(lowest!=j){
string* ptemp=pwords[j];
pwords[j]=pwords[lowest];
pwords[lowest]=ptemp;
}
}
for(int i=0;i<word_count;i++)
cout<<endl<<*pwords[i];
cout<<endl;
return 0;
}

====================================
F:\MyC\test2.cpp(15) : error C2065: 'getline' : undeclared identifier
====================================
谁能帮我看下这个程序的错误?谢谢了!
找了一下午也没找出来,闷...
...全文
183 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Atai-Lu 2007-03-19
  • 打赏
  • 举报
回复
taodm(taodm) ( ) 信誉:100 Blog 2007-03-19 09:17:01 得分: 0


用using namespace std;
VC6恐怕没有实现koenig查找规则。
====================
谢谢!问题已经解决
taodm 2007-03-19
  • 打赏
  • 举报
回复
用using namespace std;
VC6恐怕没有实现koenig查找规则。
Atai-Lu 2007-03-18
  • 打赏
  • 举报
回复
我用的是VC++ 6.0,编译不了啊!有知道这个问题的没有?
snprintf 2007-03-18
  • 打赏
  • 举报
回复
VS2005 也可以正确编译
believefym 2007-03-18
  • 打赏
  • 举报
回复
devcpp可以正确编译

64,683

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧