[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: My First Computer
In article <b26fh8$lc5$1@barad-dur.nas.com>,
White Flame \(aka David Holz\) <whiteflame52@y.a.h.o.o.com> wrote:
> "Paul Schlyter" <pausch@saaf.se> wrote in message
> news:b257si$18br$1@merope.saaf.se...
>> but of course virtually any actual C programmer would prefer this:
>>
>> main()
>> {
>> for(;;)
>> printf( "Hello\n" );
>> }
>
> Actually, I'd be more prone to write
>
> main()
> {
> while(1)
> printf( "Hello\n" );
> }
>
> I never use for(;;) for some reason. Probably because I think it's
> a little less intuitive and a little more ugly than while(1).
I prefer for(;;) over while(1) because for(;;) is more efficient:
no condition needs to be evaluated.
But you can hide the ugliness behind a macro:
#define FOREVER for(;;)
or
#define FOREVER while(1)
depending on your preferences.
--
----------------------------------------------------------------
Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40, S-114 38 Stockholm, SWEDEN
e-mail: pausch at saaf dot se
WWW: http://hem.passagen.se/pausch/index.html
http://home.tiscali.se/~pausch/