Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!samsung!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: compare strings, strcmp Keywords: strcmp,strings Message-ID: <11605@smoke.BRL.MIL> Date: 15 Nov 89 22:48:00 GMT References: <4463@blake.acs.washington.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 16 In article <4463@blake.acs.washington.edu> jimli@blake.acs.washington.edu (Jimmy Li) writes: >char array[10000][200]; >What is the fastest way to sort this array? Dump it into an external file and invoke the system sort utility on the file. You could also use qsort(), but this is such a ridiculously large amount of storage to statically allocate that you should be thinking of alternatives. >(I heard that 'strcmp' is slow if the strings are long. Why?) No, strcmp() is not particularly slow unless the strings typically differ only after the Nth character where N >> 1. Many of us use a macro like the following for simple string equality testing, to save the function-call overhead for typical strcmp() implementations: #define StrEq( a, b ) (*(a) == *(b) && strcmp( a, b ) == 0) /* UNSAFE */