Re: A note on personal corruption as a result of using C



spinoza1111 <spinoza1111@xxxxxxxxx> writes:

On Feb 18, 3:25 pm, "Clive D. W. Feather" <cl...@on-the-
train.demon.co.uk> wrote:
<snip>
Once upon a time, Edward wrote a piece of code that went something like
this (I haven't memorised it, so exact details might be wrong):

    for (intIndex = 0; intIndex < strlen (strString); intIndex++)
        strCopy [intIndex] = strString [intIndex];

Don't worry too much about the detail; the key points are the use of
strlen in the loop test and the fact that the string is not modified by
the loop body.

Somebody pointed out that this was inefficient because strlen() gets
called every time round the loop and it would be better to compute it
once and store it in a variable. For some reason he seems to think that
this was a personal attack and, rather than accepting he misremembered
the semantics of loops in C, claims that the condition *should* be
evaluated only once. Or something like that - it's not always easy to
understand our Edward.

You proceeded to make the same mistake in your bubble sort. And your
tone is vicious here, because you know you did, and you also know that
because people are afraid of your status, you weren't hounded.

Please back this up with a link to the message in question. You will
then be seen to be right. Simple. You need to do this because I
can't find it and that makes me think it does not exist.

You have not replied to my message where I link to the message I
*think* you mean and which then explains where I think your
misunderstanding comes from. All you have to do is say, "no, not that
one, this one" (with a link).

--
Ben.
.



Relevant Pages

  • Re: For loop and while loop. which one is faster?
    ... don't worry about that. ... the only possible difference between a for loop and a while loop ... is the jump prediction in your architecture's code instruction set. ... trust your compiler ...
    (comp.lang.php)
  • Re: Two date pickers
    ... ooooh I'm sure you could eliminate that loop ... not promising anything though... ... You shouldn't have to worry about that. ...
    (microsoft.public.vb.general.discussion)
  • Re: String Of Text (Number of Pixels / Pixel Size / Pixel Length)
    ... item one at a time inside a foreach($aNames as $sName) loop, ... pixel-based browser at all. ... The general rule is that you worry about the content, ...
    (comp.lang.php)
  • Re: Print elements of vector
    ... > Assume they contain strings. ... a for loop can be done. ... worry about something like this. ... a vector is just an easy interface for a linked ...
    (comp.lang.cpp)