compare strings, strcmp
mcdonald at uxe.cso.uiuc.edu
mcdonald at uxe.cso.uiuc.edu
Sun Nov 19 12:38:31 AEST 1989
>I wanted to know what is the best way to compare two strings?
>For example, I have the following decl.
>char array[10000][200];
>What is the fastest way to sort this array? (I heard that 'strcmp' is slow
>if the strings are long. Why?)
Someone suggested writing to disk and using an external sort program.
That seems a little extreme, especially since the vast majority of
routines don't HAVE an external sort routine. The C "qsort" is
surely worth a try, otherwise we really should suggest books for him to
read.
I don't understand the flames about the "unsafe"
StrEq macro. Look folks, lots of things are unsafe - motorcycles,
steaks, C. For safety you need a toy language. A simple suggestion -
is it REALLY too hard to follow? - is to RTFM, which should warn about
unsafe uses of functions or macros - or to RTF actual declaration of
the macro itself. The question is moot if he calls "qsort",
as it requires a function, not a macro.
Doug McDonald
More information about the Comp.lang.c
mailing list