Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <kst-u@mib.org> |
| Newsgroups | comp.lang.c |
| Subject | Re: Issues with array, strlen, etc |
| Date | Thu, 10 Sep 2015 10:21:42 -0700 |
| Organization | None to speak of |
| Lines | 34 |
| Message-ID | <lnmvwunqah.fsf@kst-u.example.com> (permalink) |
| References | <1866812f-e415-44b4-8127-8e21c4a13653@googlegroups.com> <1e5f8717-847a-451c-8e50-7e87115ead51@googlegroups.com> <lnlhcgsxs9.fsf@kst-u.example.com> <061a430f-e33f-4661-a8c5-506bf106c590@googlegroups.com> <MjbIx.485700$8E7.431470@fx29.am4> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="23168"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FrpmHhFIg0P/REvD8V+0l" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:8oSxz8Fw54bl0MErvSs6qz+jR8A= sha1:x+AlUyhfU7UJ/HrI/EHa2hdK7lE= |
| Xref | csiph.com comp.lang.c:70183 |
Show key headers only | View raw
Richard Heathfield <rjh@cpax.org.uk> writes:
> On 10/09/2015 09:22, Alla _ wrote:
>>
>>> This evaluates strlen(card_number) each time through the loop,
>
> No, it doesn't. Keith is wrong. That doesn't happen very often, but it
> happened this time.
[...]
>> Keith, thank you very much. I have revised
>> parts with strlen. I guess I see the difference;
>
> That's interesting, because he's wrong. Here's why:
>
> In this loop:
>
> for(x; y; z)
> {
> the_loop_body;
> }
>
> x is only executed once, at the beginning. y, z, and the_loop_body are
> executed once *per loop iteration*. If your strlen call had been in any
> of those places, Keith would have been perfectly correct. So the lesson
> is still worth learning, even if on this occasion Keith very slightly
> mis-read your code.
Oh, crud. Richard, you are of course absolutely correct. Alla, sorry
about the confusion.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Issues with array, strlen, etc Alla _ <modelling.data@gmail.com> - 2015-09-07 10:47 -0700
Re: Issues with array, strlen, etc James Kuyper <jameskuyper@verizon.net> - 2015-09-07 14:47 -0400
Re: Issues with array, strlen, etc bartekltg <bartekltg@gmail.com> - 2015-09-07 22:03 +0200
Re: Issues with array, strlen, etc Paul N <gw7rib@aol.com> - 2015-09-07 13:08 -0700
Re: Issues with array, strlen, etc Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-07 22:55 +0100
Re: Issues with array, strlen, etc Rosario19 <Ros@invalid.invalid> - 2015-09-08 07:59 +0200
Re: Issues with array, strlen, etc Rosario19 <Ros@invalid.invalid> - 2015-09-08 08:05 +0200
Re: Issues with array, strlen, etc Barry Schwarz <schwarzb@dqel.com> - 2015-09-07 20:35 -0700
Re: Issues with array, strlen, etc Alla _ <modelling.data@gmail.com> - 2015-09-08 01:08 -0700
Re: Issues with array, strlen, etc Keith Thompson <kst-u@mib.org> - 2015-09-08 09:04 -0700
Re: Issues with array, strlen, etc Alla _ <modelling.data@gmail.com> - 2015-09-10 01:22 -0700
Re: Issues with array, strlen, etc Richard Heathfield <rjh@cpax.org.uk> - 2015-09-10 09:38 +0100
Re: Issues with array, strlen, etc Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-10 07:34 -0400
Re: Issues with array, strlen, etc David Brown <david.brown@hesbynett.no> - 2015-09-10 13:47 +0200
Re: Issues with array, strlen, etc Richard Heathfield <rjh@cpax.org.uk> - 2015-09-10 13:11 +0100
Re: Issues with array, strlen, etc Keith Thompson <kst-u@mib.org> - 2015-09-10 10:21 -0700
Re: Issues with array, strlen, etc Geoff <geoff@invalid.invalid> - 2015-09-10 10:42 -0700
Re: Issues with array, strlen, etc Alla _ <modelling.data@gmail.com> - 2015-09-08 01:11 -0700
Re: Issues with array, strlen, etc Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-08 09:51 +0100
Re: Issues with array, strlen, etc Alla _ <modelling.data@gmail.com> - 2015-09-08 02:39 -0700
csiph-web