468,512 Members | 1,405 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

what does "for( ; ; )" mean in C program

hello group,
what does for( ; ; ) mean in C program

Thanks
Feb 1 '08 #1
13 7381
In article <25**********************************@j20g2000hsi. googlegroups.com>,
bobby <bs*****@gmail.comwrote:
>what does for( ; ; ) mean in C program
This is a loop.

Do no initializations.

Do not test any condition to see whether you should continue.

Do not do anything after the end of a loop before the beginning
of the next loop through.
In summary: for(;;) is another way of writing while (1)
which is an infinite loop (unless broken out of somewhere
in the middle.)
--
'Roberson' is my family name; my given name is 'Walter'.
Feb 1 '08 #2
On Feb 1, 3:52 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <25dd47d5-b599-4ed0-8f9d-9b84936a8...@j20g2000hsi.googlegroups.com>,

bobby <bsim...@gmail.comwrote:
what does for( ; ; ) mean in C program

This is a loop.

Do no initializations.

Do not test any condition to see whether you should continue.

Do not do anything after the end of a loop before the beginning
of the next loop through.

In summary: for(;;) is another way of writing while (1)
which is an infinite loop (unless broken out of somewhere
in the middle.)
--
'Roberson' is my family name; my given name is 'Walter'.
Thank a lot
Feb 1 '08 #3
bobby wrote:
hello group,
what does for( ; ; ) mean in C program
while (1)

Feb 1 '08 #4
In article <60*************@mid.individual.net>,
Martin Ambuhl <ma*****@earthlink.netwrote:
>bobby wrote:
>hello group,
what does for( ; ; ) mean in C program

while (1)
I always thought it meant:

while(27)

I guess it depends on what part of town you're from.

Feb 1 '08 #5
sid
On Feb 2, 1:48*am, bobby <bsim...@gmail.comwrote:
hello group,
what does for( ; ; ) mean in C program

Thanks
It also means for(;1;);
A 'while()' loop is equivalent to 'for(;;)'
Feb 2 '08 #6
sid <ki***********@gmail.comwrites:
A 'while()' loop is equivalent to 'for(;;)'
while() is not valid syntax. I think you mean that a while(1)
loop is equivalent to for(;;).
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
Feb 2 '08 #7
Ben Pfaff:
sid <ki***********@gmail.comwrites:
>A 'while()' loop is equivalent to 'for(;;)'

while() is not valid syntax. I think you mean that a while(1)
loop is equivalent to for(;;).

But the extra-paranoid don't use it coz they don't want 1 to be evaluted
upon every iteration ;-)

--
Toms hilidhe
Feb 2 '08 #8
Harald van Dijk <tr*****@gmail.comwrites:
Some people avoid using while(1) because they have to deal with broken
tools that give warnings for while(1) that they don't give for for(;;).
for(;;) is also one character shorter then while(1). :P

--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
Feb 2 '08 #9
"Michal Nazarewicz" <mi****@tlen.plwrote in message
news:87************@erwin.mina86.com...
Harald van Dijk <tr*****@gmail.comwrites:
>Some people avoid using while(1) because they have to deal with broken
tools that give warnings for while(1) that they don't give for for(;;).

for(;;) is also one character shorter then while(1). :P
:^)

Feb 2 '08 #10
On Feb 2, 2:43 am, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
In article <60hgo6F1q946...@mid.individual.net>,
Martin Ambuhl <mamb...@earthlink.netwrote:
bobby wrote:
hello group,
what does for( ; ; ) mean in C program
while (1)

I always thought it meant:

while(27)

I guess it depends on what part of town you're from.
nah .. its actually while(42) :P
Feb 2 '08 #11

"bobby" <bs*****@gmail.comha scritto nel messaggio
news:25**********************************@j20g2000 hsi.googlegroups.com...
hello group,
what does for( ; ; ) mean in C program

Thanks
#define ever (;;)

for ever

Feb 3 '08 #12
"runner" <emb@ddedwrites:
"bobby" <bs*****@gmail.comha scritto nel messaggio
news:25**********************************@j20g2000 hsi.googlegroups.com...
>hello group,
what does for( ; ; ) mean in C program
#define ever (;;)

for ever
If your goal is to be cute, by all means go ahead and use that macro.

If your goal is to write understandable and maintainable C, please
don't.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Feb 3 '08 #13

"Keith Thompson" <ks***@mib.orgha scritto nel messaggio
news:87************@kvetch.smov.org...
"runner" <emb@ddedwrites:
>"bobby" <bs*****@gmail.comha scritto nel messaggio
news:25**********************************@j20g200 0hsi.googlegroups.com...
>>hello group,
what does for( ; ; ) mean in C program
>#define ever (;;)

for ever
>
If your goal is to be cute, by all means go ahead and use that macro.

If your goal is to write understandable and maintainable C, please
don't.
I'm being cute, i don't need that macro. But it does its job in explaining
what happens when no expression is provided.

--
Feb 4 '08 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by lkrubner | last post: by
reply views Thread by Claudio Grondi | last post: by
5 posts views Thread by Steven T. Hatton | last post: by
9 posts views Thread by Marek Kurowski | last post: by
6 posts views Thread by Juan Romero | last post: by
39 posts views Thread by utab | last post: by
5 posts views Thread by chandanlinster | last post: by
4 posts views Thread by chandanlinster | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.