strcmp ?

Hi,

facing some issues, strcmp doesnt seems to work.

bool returnScaleText(const char* scaleText)
{


std::vector<std::string> scale;
scale.push_back("1:1");scale.push_back("1:2");
scale.push_back("1:4");scale.push_back("1:8");
scale.push_back("1:10");scale.push_back("1:20");
scale.push_back("2:1");scale.push_back("4:1");
scale.push_back("5:1");scale.push_back("8:1");
scale.push_back("10:1");scale.push_back("20:1");
scale.push_back("50:1");scale.push_back("100:1");

std::vector<string>::iterator it;


for ( it = scale.begin(); it != scale.end(); it++ )
{
string itCtr=*it;

if(strcmp(scaleText,itCtr.c_str()) == 0 )
{
return true;
}
}

return false;
}
That code appears ok. Maybe the problem is elsewhere in your program code?

However, since you use std::string, there's no need to use strcmp() at all
1
2
3
4
5
6
7
    for ( it = scale.begin(); it != scale.end(); it++ )
    {
        if ( *it == scaleText )
        {
            return true;
        }
    }
@Chervil

Long time boss
Topic archived. No new replies allowed.