新手,求助!
#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
====================================
谁能帮我看下这个程序的错误?谢谢了!
找了一下午也没找出来,闷...