I'm new at programming and I can't figure this out. Can anyone please help?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
bool nocase_compare (char c1, char c2)
{
return toupper(c1) == toupper(c2);
}
int main( int argc, char* argv[] )
{
ifstream infile;
string filename;
do
{
cout << "File name? ";
cin >> filename;
infile.open(filename.c_str());
if (!infile)
{
cerr << "Cannot open file: " << filename << "\n" << endl;
return 0;
}
} while (!infile);
string line;
string search;
int counter = 0;
size_t found=' ';
cout << "Search string? ";
cin >>search;
string::iterator pos;
pos = search (line.begin(),line.end(),
search.begin(),
search.end(),
[COLOR="red"]nocase_compare);[/COLOR] [COLOR="red"]<===Error[/COLOR]
if (pos == line.end())
{
cout <<"not found";
}
else
{
cout<<"found";
}
infile.close();
system("pause");
return 0;
}
error C2064: term does not evaluate to a function taking 5 arguments