jaZon All American 27048 Posts user info edit post |
Ok, I need to read all the lines from a file and run a custom search in each line.
Fine.
int main(int argc, char* argv[]) {
char* pattern = argv[1]; string line; ifstream myFile(argv[2]);
if (myFile.is_open()) { while (!myFile.eof()) { getline(myFile,line); if (search(pattern, line) == true) { cout << "yep"; } } myFile.close(); } }
The search function is defined as:
bool search(char pattern[], char text[]);
Problem being it won't compile due to the type mismatch.
Quote : | " error: cannot convert `std::string' to `char*' for argument `2' to `bool search(char*, char*)"" |
Help?9/21/2006 8:58:03 PM |