param is a char*; that's basically just an integer as far as the
computer is concerned. Basically, what's happening is that the
compiler is comparing the addresses of the two pointers. To
compare char*'s, you must use the function strcmp():
--PaulCode:char* str1 = "hi"; char* str2 = "hi2"; if (strcmp(str1, str2) == 0) { // strings are equal in here } else if (strcmp(str1, str2) < 0) { // str1 is less than str2 in h ere } else { // str2 is less than str1 in here }




Reply With Quote