Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 05-03-2008, 10:19 PM   #1 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default 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 by frogonfloor; 06-03-2008 at 08:59 PM.
frogonfloor is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 05-03-2008, 10:34 PM   #2 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,772
Default Re: need help in C

Nope.. U can use it without any conditions but like this
for(;
{}
it ll be an infinite loop
__________________
My new blog: www.pathikshah.com
Pathik is offline  
Old 05-03-2008, 10:42 PM   #3 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default Re: need help in C

for(;
{}


It is giving syntax error . no matter it is infinite loop but it should run .
frogonfloor is offline  
Old 05-03-2008, 11:15 PM   #4 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,772
Default Re: need help in C

damn the smiley.. use
Code:
for(;;){}
__________________
My new blog: www.pathikshah.com
Pathik is offline  
Old 06-03-2008, 12:15 PM   #5 (permalink)
The Frozen Nova
 
casanova's Avatar
 
Join Date: Sep 2004
Location: Trespasser in Virtual Land
Posts: 1,641
Default Re: need help in C

Or while (1)
__________________
I dream of a better tomorrow... where chickens can cross roads and not have their motives questioned.

www.nerdweed.blogspot.com
casanova is offline  
Old 06-03-2008, 12:52 PM   #6 (permalink)
Console Junkie
 
aditya.shevade's Avatar
 
Join Date: Jun 2006
Location: USA
Posts: 991
Default Re: need help in C

why do you want it though?

The best way to create an infinite loop is,
Code:
while(TRUE)
__________________
--- Console Junkie
aditya.shevade is offline  
Old 06-03-2008, 05:45 PM   #7 (permalink)
18 Till I Die............
 
Join Date: Jul 2004
Location: India, Mumbai, Marine Lines
Posts: 5,792
Default Re: need help in C

Quote:
Originally Posted by casanova View Post
Or while (1)
Quote:
Originally Posted by aditya.shevade View Post

The best way to create an infinite loop is,
Code:
while(TRUE)
Don't both mean the same?
__________________
http://www.bash.org/?258908
mehulved is offline  
Old 06-03-2008, 06:11 PM   #8 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default Re: need help in C

Quote:
Originally Posted by Pathik View Post
Nope.. U can use it without any conditions but like this
for(;
{}
it ll be an infinite loop
lol
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Old 06-03-2008, 07:07 PM   #9 (permalink)
Console Junkie
 
aditya.shevade's Avatar
 
Join Date: Jun 2006
Location: USA
Posts: 991
Default Re: need help in C

Quote:
Originally Posted by mehulved View Post
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.
__________________
--- Console Junkie
aditya.shevade is offline  
Old 06-03-2008, 08:53 PM   #10 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default Re: need help in C

friends i said there should not be any condition in bracket and it should run . no matter what the output is . but i think
Quote:
for(;{}
is right
frogonfloor is offline  
Old 06-03-2008, 10:34 PM   #11 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: need help in C

What do you mean you think? Why don't you try it first before asking? Or was this a test question?
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 06-03-2008, 10:37 PM   #12 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default Re: need help in C

i tried this one and thanks to Pathik and others for helping .

does one one know how to Obfuscate c code
frogonfloor is offline  
Old 06-03-2008, 11:15 PM   #13 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: need help in C

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.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 07-03-2008, 07:25 AM   #14 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default Re: need help in C

can u explain it a bit more
frogonfloor is offline  
Old 07-03-2008, 11:01 AM   #15 (permalink)
Who stole my Alpaca!
 
FilledVoid's Avatar
 
Join Date: Jan 2005
Location: Kerala
Posts: 2,020
Default Re: need help in C

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.
__________________
The Ultimate Chess Strategy : "Hit Hard, Hit Fast and Hit Often"
FilledVoid is offline  
Old 07-03-2008, 09:01 PM   #16 (permalink)
Apprentice
 
Join Date: Aug 2007
Posts: 50
Default Re: need help in C

thanks for explaning .
can u tell me how to Obfuscate c code
frogonfloor is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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 On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:53 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2