i wanted to compare two strings in a conditional. but
wont' work.Code:if (string1==string2)
i wanted to compare two strings in a conditional. but
wont' work.Code:if (string1==string2)
As long as your compiler supports that function.
strncmp() is another standard function you can use if you only want to compare part of a string.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
stricmp variant is for case insensitivity. Not "lowercase".
Just so you're aware of what's going, you're comparing pointers. So instead of comparing the array like you want to, you're comparing two variables that contain memory addresses. So unless the two pointers both point to the exact same location in memory, they're not equal - even if they point to the same data.if (string1==string2)
strcmp compares the arrays element by element.