Your strcmp approach appears to be correct, so perhaps it's some other bug?