首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

新手,

2012-04-01 
新手,求助!#include iostream#include stringusingstd::coutusingstd::cinusingstd::endlusingstd:

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


[解决办法]
用using namespace std;
VC6恐怕没有实现koenig查找规则。

热点排行