If str
is a string C (an array of characters with a null character), then str[0]
is char.
Please note that the type of quotes matters! ')'
is a char, and ")"
is a string (i.e. a ')'
char followed by a null terminator).
So you can compare two characters:
str[0] == ')'
or you can compare two lines
strcmp(str, ")") == 0
Naturally, (the second works if the string str
really contains only this bracket).
Imp source share