"cp**********@yahoo.com" <cp**********@yahoo.comwrites:
Could some C guru provide some hints on my problem? I am trying to
sort an array of character strings, where each string contains
lowercase, uppercase, digits as well as non-alphanumeric characters as
'-', '(' or '/'. Obviously, standard C functions as 'strcmp' would
fail in these cases.
What's obvious about that?
I can convert all the non-digit characters to
lowercase, but how do I deal with the non-alphanumeric characters?
I don't know. How do you want to deal with non-alphanumeric characters?
Using strcmp() directly is certainly a valid way to sort strings, but
you apparently want to map uppercase letters to lowercase before
comparing them. That still leaves a plethora of ways you might want
to compare strings that contain things other than letters. We have no
way of knowing (and C doesn't define) which of those ways is valid.
You need to decide how you want to do the comparisons. Once you've
done that, it's likely you'll be able to implement the comparison in C
yourself. If not, show us what you've tried and we can help you fix
it.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"