From owner-freebsd-chat Tue Jan 23 2:43:47 2001 Delivered-To: freebsd-chat@freebsd.org Received: from ns5.pacific.net.au (ns5.pacific.net.au [203.143.252.30]) by hub.freebsd.org (Postfix) with ESMTP id 1EB8D37B402 for ; Tue, 23 Jan 2001 02:43:27 -0800 (PST) Received: from dungeon.home (ppp150.dyn249.pacific.net.au [203.143.249.150]) by ns5.pacific.net.au (8.9.0/8.9.1) with ESMTP id VAA15891; Tue, 23 Jan 2001 21:43:24 +1100 (EST) Received: from dungeon.home (localhost [127.0.0.1]) by dungeon.home (8.11.1/8.9.3) with ESMTP id f0NAi3I22973; Tue, 23 Jan 2001 20:44:03 +1000 (EST) (envelope-from mckay) Message-Id: <200101231044.f0NAi3I22973@dungeon.home> To: Stanislav Grozev Cc: freebsd-chat@freebsd.org, mckay@thehub.com.au Subject: Re: silly C style question References: <20010122170600.D4456@dogma.freebsd-uk.eu.org> <200101231023.f0NANZI18506@dungeon.home> <20010123122823.B26056@thing.orbitel.bg> In-Reply-To: <20010123122823.B26056@thing.orbitel.bg> from Stanislav Grozev at "Tue, 23 Jan 2001 12:28:23 +0200" Date: Tue, 23 Jan 2001 20:44:03 +1000 From: Stephen McKay Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Tuesday, 23rd January 2001, Stanislav Grozev wrote: >On Tue, Jan 23, 2001 at 08:23:35PM +1000, Stephen McKay wrote: >> Use neither of these! Use: >> >> if (i == 0) >> { >> foo(i); >> bar(i); >> } >> >> You Know It Makes Sense(tm). > >please elaborate how your solution makes sense? because I am obviously dumb, >as I can't seem to recognize the reasoning behind it.;-)) The structure is: if (expression) statement; statement consists of two statements foo(i) and bar(i) in this case. So, it becomes: if (expression) compound-statement The compound-statement must be surrounded with brackets to make it work. I line them up with the statements within the compound-statement because the brackets are part of the compound-statement. (Old Pascal thinking showing through, but it still works in C). Yields: if (expression) { statement1; statement2; } Completely logical! Stephen. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message