Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jan 2001 20:44:03 +1000
From:      Stephen McKay <mckay@thehub.com.au>
To:        Stanislav Grozev <sgrozev@orbitel.bg>
Cc:        freebsd-chat@freebsd.org, mckay@thehub.com.au
Subject:   Re: silly C style question 
Message-ID:  <200101231044.f0NAi3I22973@dungeon.home>
In-Reply-To: <20010123122823.B26056@thing.orbitel.bg> from Stanislav Grozev at "Tue, 23 Jan 2001 12:28:23 %2B0200"
References:  <20010122170600.D4456@dogma.freebsd-uk.eu.org> <200101231023.f0NANZI18506@dungeon.home> <20010123122823.B26056@thing.orbitel.bg>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101231044.f0NAi3I22973>