Trying to construct a match function

I am trying to construct a match function that can take a char* and see if the contents of the char pointer is equal to a string. This is what I have so far an I know it is obviously wrong.

1
2
3
4
5
6
7
8
9
10
void match(string matchCriteria)
{
    if (strcmp(result, matchCriteria) == 0)
    {
        cout << "---Match Accepted\r\n";
        nextToken();
    }
    else
        cout << "Error thrown: Expected " << matchCriteria << "\r\n";
}


result is a global variable.

Any help would be greatly appreciated.
use .c_str()
1
2
3
4
5
6
7
8
9
10
void match(string matchCriteria)
{
    if (strcmp(result, matchCriteria.c_str() ) == 0) //use member function of string to get a cstring
    {
        cout << "---Match Accepted\r\n";
        nextToken();
    }
    else
        cout << "Error thrown: Expected " << matchCriteria << "\r\n";
}
Topic archived. No new replies allowed.