My question is, what is that comparison doing. Is it comparing the memory address of those two variables? Or what?Code:char a[10] = "123"; char b[10] = "234"; if (a > b) { printf("here"); }
My question is, what is that comparison doing. Is it comparing the memory address of those two variables? Or what?Code:char a[10] = "123"; char b[10] = "234"; if (a > b) { printf("here"); }
Yes it is comparing the memory address of those two variables. (The value of "a", by itself, is not a member of the array a but the beginning address of the array. Same for "b".)
You can loop through and compare each character, or you can ... do the same exact thing, disguised as a single function call, using something like strcmp. Assuming of course that you do have strings and not just non-nul-terminated-arrays.
Quzah.
Hope is the first step on the road to disappointment.