Let's say we have the two strings FOOBAR and BFORAO. While not really equal as strings, they contain exactly the same characters and according to my needs, I can treat them as equal. And I will be calling them "equal" from now on to avoid typing again and again long sentences.
I need a fast way to check if two strings are equal.
As far as I know, the strspn() function will take two strings, and if all the characters of string2 appear in string1, it will return string1's length. Good. But what if I compare FOOBAR against BAR? Indeed, every character from string2 appears in string1... but... not vice-versa. Hm, I could possible run strspn() for one more time, this time reverted (a.k.a. checking BAR against FOOBAR). If the two outputs are the same, bingo. The two strings are equal.
But is it efficient enough? I need to do this for more than 400K strings, and although I have a dual-core with 6GB of RAM, the process needs to be completed in a relatively small time-frame. I haven't actually started on this program yet, I'm still looking for the most efficient way to accomplishe the task I've described.
Any ideas?
Maybe evaluating each string "by hand" (running tests inside nested loops against every individual character, etc.) would be faster than the solution I've thought of using the string header?