greghua
April 9th, 2005, 09:49 PM
#include <iostream>
#include <string>
#include <functional>
using namespace std;
int count(const string& s, char c)
{
string::iterator i=find(s.begin(),s.end(),c);
int n=0;
while(i!=s.end())
{
++n;
i=find(i+1,s.end(),c);
}
return n;
}
void main()
{
cout<<cout("Abcdiadcsa",'a')<<endl;
}
when compile, compiler says that find is an undeclared identifier.
find is a standard algorithm, should i include any other head file?
#include <string>
#include <functional>
using namespace std;
int count(const string& s, char c)
{
string::iterator i=find(s.begin(),s.end(),c);
int n=0;
while(i!=s.end())
{
++n;
i=find(i+1,s.end(),c);
}
return n;
}
void main()
{
cout<<cout("Abcdiadcsa",'a')<<endl;
}
when compile, compiler says that find is an undeclared identifier.
find is a standard algorithm, should i include any other head file?