need help in C

Status
Not open for further replies.

frogonfloor

Broken In
Joined
Aug 8, 2007
Messages
50
need help in C ( using for loop without condition in bracket )

Hi friends i want to ask one question . this is realy crazy question but still i am asking
can we use for loop without giving any condition in bracket
i mean for() nothing in bracket .
 
Last edited:

Pathik

Google Bot
Joined
Aug 28, 2005
Messages
9,684
Nope.. U can use it without any conditions but like this
for(;;)
{}
it ll be an infinite loop
 
OP
F

frogonfloor

Broken In
Joined
Aug 8, 2007
Messages
50
for(;
{}


It is giving syntax error . no matter it is infinite loop but it should run .
 

aditya.shevade

Console Junkie
Joined
Jun 29, 2006
Messages
988
why do you want it though?

The best way to create an infinite loop is,
Code:
while(TRUE)
 

aditya.shevade

Console Junkie
Joined
Jun 29, 2006
Messages
988
Don't both mean the same?

Yeah they mean the same.... I just use TRUE and FALSE because it is easier to understand than while 1 or 0. Theoretically, you can use any non zero positive integer to indicate TRUE.
 

QwertyManiac

Commander in Chief
Joined
Jul 17, 2005
Messages
6,575
What do you mean you think? Why don't you try it first before asking? Or was this a test question? :?
 
OP
F

frogonfloor

Broken In
Joined
Aug 8, 2007
Messages
50
i tried this one and thanks to Pathik and others for helping .

does one one know how to Obfuscate c code
 

QwertyManiac

Commander in Chief
Joined
Jul 17, 2005
Messages
6,575
I guess doing a near-proper disassembly of the code should give you enough obfuscation?

Or... I might just be repeating a heard bluff here.
 

FilledVoid

Who stole my Alpaca!
Joined
Jan 4, 2005
Messages
1,826
Code:
for(;;)
{

}

Any part of the for statement can be left out . However the semicolons must be used in any case. The above gives you an infinite loop cause there is no condition being tested for , no variable being initialized as a counter in it or incrementing / decrementing the counter in it. Unless you know what you were doing you would not use this syntax in one of your programs.
 
Status
Not open for further replies.
Top