simple comparing isn't working??

Sep 28, 2014 at 7:19pm
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;
    }
    
}
Sep 28, 2014 at 7:36pm
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.

Sep 28, 2014 at 7:56pm
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)

Sep 28, 2014 at 8:02pm
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.