Hey,
Basically, I have 3 pointers, all of which were returned from different strchr calls on the same string, with different search characters.
So, from these 3 pointers I want to find which one of these characters occurs first
My method of doing this is something like
Code:
if(((p1 < p2) || (p2 == NULL)) && ((p1 < p3) || (p3 == NULL))
To check if p1 is first, taking into account p2 and p3 might be NULL.
My question is this: Is the above snippet of code 'correct'? As in, is it safe to assume for any given string, and any 3 pointers to characters in that string retrieved using strchr, on any modern machine, the above would work as expected?
I'm fairly confident that it's logically sound, but I'd greatly appreciate input on this matter.
Thanks in advanced.