Article View: comp.std.c
Article #4230Re: order of execution with && and ||
From: Christopher R. Volpe
Date: Mon, 16 Oct 1995 13:05
Date: Mon, 16 Oct 1995 13:05
22 lines
1406 bytes
1406 bytes
In article <45psab$fnf@umbc9.umbc.edu>, schlein@umbc.edu (Jonas J. Schlein) writes: >|> What is the order of execution (resolution) for statements with && and ||? >|> >|> E.G. Given the following: >|> >|> if (ptr != (char *) 0 && *ptr == 'a') >|> >|> does this get resolved left to right? > >If by left to right you mean, "Will (ptr != (char *) 0) be executed before >(*ptr == 'a')?" then the answer is yes. Actually in your case all 3 operators, >i.e. !=, &&, and ==, are left to right associativity so you're perfectly Associativity has nothing to do with order of evaluation. And it has nothing to do with the above example because you don't have a sequence of consecutive operators that all have the same precedence level. -- Chris Volpe Phone: (518) 387-7766 (Dial Comm 8*833 GE Corporate R&D Fax: (518) 387-6560 PO Box 8, Schenectady, NY 12301 Email: volpecr@crd.ge.com
Technical Details
Message-ID:
<45tl9s$rs@rdsunx.crd.ge.com>Path:
arc1-ca.pugleaf.net!bart.crd.ge.com!volpeReferences:
<45bbtn$t8o@goanna.cs.rmit.EDU.AU> <45psab$fnf@umbc9.umbc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe From: volpe@bart.crd.ge.com (Christopher R. Volpe) Newsgroups: comp.std.c Subject: Re: order of execution with && and || Date: 16 Oct 1995 13:05:00 GMT Organization: GE Corporate Research & Development Sender: volpe@bart (Christopher R. Volpe) Distribution: world Message-ID: <45tl9s$rs@rdsunx.crd.ge.com> References: <45bbtn$t8o@goanna.cs.rmit.EDU.AU> <45psab$fnf@umbc9.umbc.edu> Reply-To: volpe@ausable.crd.ge.com NNTP-Posting-Host: bart.crd.ge.com