I have the following:
int findPar(char* str)
{
int counter=0;
while (*str)
{
if(str[0] == "(") <---- Warning
{
counter++;
}
else if (str[0]== ")") <---- Warning
{
counter--;
}
if (counter<0)
{
return 0;
}
str++;
}
if (counter!=0)
{
return 0;
}
return 1;
}
The warning i get is comparison between an int and a char.
I tried to do the comparison (first char in the string vs. given char) also with strcmp like this:
if (strcmp(str, ")")==0) { stuff }
but it never goes in to 'stuff' even when the comparison (should) be correct.
how should i do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…