simple comparing isn't working??

I am trying to convert a string to a int but seems to have some problems using the function.. Anyone who could see what is going wrong?

1
2
3
4
5
6
7
8
9
10
11
int convertStringToInt(string test)
{
    if (test.compare('L') == 0) {
        return 1;
    }
    
    if (test.compare('R') == 0) {
        return 2;
    }
    
}
There is no string.compare() function that takes a single character as a parameter. Remember single quotes denote a character constant, double quotes denote a string constant.

Ok.. got it.. so i changed, but i seem to have problems reading substring.

ex.

I will not take data.at(0) as parameter when

string data = "121212121121212"
data.at(0)

You'll need to post more content, however realize data.at(0) is returning a single character, not a substring.

Topic archived. No new replies allowed.