Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault |
| Date | 2016-09-30 09:16 -0700 |
| Organization | None to speak of |
| Message-ID | <lnoa35qs6k.fsf@kst-u.example.com> (permalink) |
| References | <75ada694-4a58-4f1d-81d1-9490a709e75d@googlegroups.com> <871t01a5fo.fsf@bsb.me.uk> <4f17ee9b-c20e-4395-becb-ae79dd7cb987@googlegroups.com> |
mark.bluemel@gmail.com writes:
> On Friday, 30 September 2016 14:22:11 UTC+1, Ben Bacarisse wrote:
>> alla.rashitova@gmail.com writes:
>>
>> > I don't understand why I get segmentation fault on my while loop
>> > while(source[i] != '\n' || source[i] != '\0')
>> > when i use it to run through the line, which is stored in an array.
>>
>> A loop ends when it's condition is false, so *every time you write a loop*
>> negate the condition and check that what you get is indeed the state of
>> affairs that you want to bring about.
>
> If Ben has to explain this to you after all this time, you are still
> trying to go to fast and you are still not doing enough debugging with
> a piece of paper.
I've been programming for a long time. I have yet to stop making silly
little mistakes now and then.
--
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
while(source[i] != '\n' || source[i] != '\0') segmentation fault alla.rashitova@gmail.com - 2016-09-30 05:23 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Alla _ <modelling.data@gmail.com> - 2016-09-30 05:27 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-30 14:22 +0100
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault mark.bluemel@gmail.com - 2016-09-30 06:37 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Alla _ <modelling.data@gmail.com> - 2016-09-30 07:49 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Keith Thompson <kst-u@mib.org> - 2016-09-30 09:16 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-30 14:41 -0400
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-09-30 06:59 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Alla _ <modelling.data@gmail.com> - 2016-09-30 07:46 -0700
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-30 16:04 +0100
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Ken Brody <kenbrody@spamcop.net> - 2016-09-30 10:55 -0400
Re: while(source[i] != '\n' || source[i] != '\0') segmentation fault Barry Schwarz <schwarzb@dqel.com> - 2016-09-30 09:34 -0700
csiph-web