Re: Strcpy versus Strncpy in arrays
On 2005-11-16, Flash Gordon <spam@flash-gordon.me.uk> wrote:[color=blue]
> Jordan Abel wrote:[color=green]
>> On 2005-11-15, Mark McIntyre <markmcintyre@s pamcop.net> wrote:[color=darkred]
>>> On Tue, 15 Nov 2005 05:48:36 +0000 (UTC), in comp.lang.c , Jordan Abel
>>> <jmabel@purdue. edu> wrote:
>>>
>>>> On 2005-11-14, Mark McIntyre <markmcintyre@s pamcop.net> wrote:
>>>>> On Mon, 14 Nov 2005 21:04:25 GMT, in comp.lang.c , Keith Thompson
>>>>> <kst-u@mib.org> wrote:
>>>>>
>>>>>> I agree with "Default User". I suppose I have a slight preference for
>>>>>> postincrement, but I don't find either one counterintuitiv e or
>>>>>> jarring,
>>>>> A heck of a lot of learners do however, IME. YMMV etc. You know and I
>>>>> know that the ++ is evaluated, but the original value of i used in the
>>>>> loop body. My experience of trainees is that they find that odd.
>>>> Do what? the ++ is evaluated at the end of the loop body, and the
>>>> variable's new value is used both for the comparison and for the next
>>>> instance of the loop body. Where after the increment is the "original
>>>> value" used?
>>> Inside the body of the loop. Are you hard of reading?[/color]
>>
>> No, the new value is used. The increment happens at the end of the
>> loop, and then the new value is used for the next execution of the
>> body. At no time after it is incremented is the previous value used.[/color]
>
> I believe that Mark is talking about how people might miss-read the
> code, not how it actually works. I'm sure Mark knows how it actually works.[/color]
I read him as claiming that it works this way and that using ++i
obfuscates how it uses the previous value.
[color=blue]
>
> Beginner known that i++ returns the value from before the increment.
> Therefore beginner reads the third statement as meaning that the old
> value of i is used in the body of the loop.
> Therefore beginner has got it wrong.[/color]
How can this be used to claim that ++i is less clear, when ++i would in
that case lead to the correct conclusion?
[color=blue]
> In the above none of us are the beginner because we all know better.[/color]
On 2005-11-16, Flash Gordon <spam@flash-gordon.me.uk> wrote:[color=blue]
> Jordan Abel wrote:[color=green]
>> On 2005-11-15, Mark McIntyre <markmcintyre@s pamcop.net> wrote:[color=darkred]
>>> On Tue, 15 Nov 2005 05:48:36 +0000 (UTC), in comp.lang.c , Jordan Abel
>>> <jmabel@purdue. edu> wrote:
>>>
>>>> On 2005-11-14, Mark McIntyre <markmcintyre@s pamcop.net> wrote:
>>>>> On Mon, 14 Nov 2005 21:04:25 GMT, in comp.lang.c , Keith Thompson
>>>>> <kst-u@mib.org> wrote:
>>>>>
>>>>>> I agree with "Default User". I suppose I have a slight preference for
>>>>>> postincrement, but I don't find either one counterintuitiv e or
>>>>>> jarring,
>>>>> A heck of a lot of learners do however, IME. YMMV etc. You know and I
>>>>> know that the ++ is evaluated, but the original value of i used in the
>>>>> loop body. My experience of trainees is that they find that odd.
>>>> Do what? the ++ is evaluated at the end of the loop body, and the
>>>> variable's new value is used both for the comparison and for the next
>>>> instance of the loop body. Where after the increment is the "original
>>>> value" used?
>>> Inside the body of the loop. Are you hard of reading?[/color]
>>
>> No, the new value is used. The increment happens at the end of the
>> loop, and then the new value is used for the next execution of the
>> body. At no time after it is incremented is the previous value used.[/color]
>
> I believe that Mark is talking about how people might miss-read the
> code, not how it actually works. I'm sure Mark knows how it actually works.[/color]
I read him as claiming that it works this way and that using ++i
obfuscates how it uses the previous value.
[color=blue]
>
> Beginner known that i++ returns the value from before the increment.
> Therefore beginner reads the third statement as meaning that the old
> value of i is used in the body of the loop.
> Therefore beginner has got it wrong.[/color]
How can this be used to claim that ++i is less clear, when ++i would in
that case lead to the correct conclusion?
[color=blue]
> In the above none of us are the beginner because we all know better.[/color]
Comment