注册 登录
编程论坛 C++教室

[求助] 帮忙看下这个错误什么意思?

lyle3 发布于 2007-03-31 22:53, 588 次点击
  1. 我们第一次的作业:我写的代码是这样的:

    作业是要求计算文件中给定的单词的个数
    //: C02:file.txt
    // count the speical word's number in the file
    #include<string>
    #include<fstream>
    #include<iostream>
    using namespace std;

int main()
{
int number=0;
ifstream in ("file.txt");
string word,test;
cout<<"Please enter the word you want to quest:";
cin>>test;
while(getline(in,word," "))
{
if(word==test)
{
number++;
}
}
cout<<"The number of "<<test<<" is:"<<number<<endl;

}///:~


错误信息是这样的 :
--------------------Configuration: 111 - Debug--------------------
Compiling source file(s)...
Find.cpp
D:\课件\c++\test\Find.cpp: In function `int main()':
D:\课件\c++\test\Find.cpp:15: error: no matching function for call to `getline(
std::ifstream&, std::string&, const char[2])'
D:\课件\c++\test\Find.cpp:24:7: warning: no newline at end of file

111.exe - 1 error(s), 1 warning(s)

不知道是什么意思
大家帮忙看下
谢谢~~

3 回复
#2
lyle32007-03-31 22:57
帮忙看下。。。
谢谢
#3
RL7202007-03-31 23:52
while(getline(in,word," "))
改成
while(getline(in,word,' '))
即可
#4
lyle32007-04-01 13:30
谢谢
1