Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > main without a return statement

Reply
Thread Tools

main without a return statement

 
 
pete
Guest
Posts: n/a
 
      11-13-2007
Keith Thompson wrote:
>
> "Charlie Gordon" <(E-Mail Removed)> writes:
> [...]
> > TRUE is not really needed, nor welcome,
> > the classic idiom for this kind of loop is
> >
> > for (; { ... }

>
> Or:
>
> while (1) { ... }
>
> (Let's not have a lengthy debate about which one is clearer, better,
> and/or more idiomatic, ok?)


You've got to be kidding!!!

First of all:
for (; { ... } gives No warning on MY compiler.
(for one specific value of "me").
while(1) gives me a warning about a conditional test expression
being constant.

Second of all:
for (; { ... } is the K&R example for an endless loop.

Third of all:
It's a special rule in the language for endless loops.
for (;1; /* compiles */
for (; ; /* compiles */
while(1); /* compiles */
while( ); /* doesn't compile */

--
pete
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
without declare parameter [double square(parameter)] return 0 in main WanHongbin@gmail.com C Programming 5 10-01-2008 03:31 AM
int main(void) { return main(); } Army1987 C Programming 37 04-03-2007 06:45 AM
getting return value from function without return statement. Seong-Kook Shin C Programming 1 06-18-2004 08:19 AM
How do I return a return-code from main? wl Java 2 03-05-2004 05:15 PM



Advertisments