From: broeker AT acp3bf DOT knirsch DOT de (Hans-Bernhard Broeker) Newsgroups: comp.os.msdos.djgpp Subject: Re: strset function Date: 15 Nov 1999 18:09:53 +0100 Organization: RWTH Aachen, III. physikalisches Institut B Lines: 23 Message-ID: <80pep1$nmb@acp3bf.knirsch.de> References: <1e1batd DOT 137nbir1xiefqN AT d249 DOT paris-48 DOT cybercable DOT fr> <19b54f3c DOT 0c6b504d AT usw-ex0103-019 DOT remarq DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 942685797 18142 137.226.32.75 (15 Nov 1999 17:09:57 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 15 Nov 1999 17:09:57 GMT X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Alain Magloire (alainm AT news DOT mcgill DOT ca) wrote: > Malcolm (donald DOT mcleanNOdoSPAM AT talk21 DOT com DOT invalid) wrote: > : What does strset do ? I imagine it sets a string to all one > : character. This is easy to code [...] > Then, in that case you are better off with memset() which on most > OS/libc coded in assembly for speed. Wrong, at least for some applications. The difference is that you have to know the length of the string to be 'blanked out', before you can call memset(), i.e. strset(string, c) would be equivalent to memset(string, c, strlen(string)); That's two loops over the string, one to find its end, the second to fill it with 'c'. Almost certainly slower than strset, if that is implemented in the straightforward way demonstrated by the posting you answered to. Two loops doing so little are practically always slower than one, even if both of them are especially cleverly written, and the single loop is just compiled ordinarily. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.