Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 20th, 2004, 12:25 PM   #1
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
Ok, I know this is pointless but, could you use the 'continue' comand with an 'if' statement to create a loop?

I know a 'while' or 'for' would be a lot easier but still just wondering
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Oct 20th, 2004, 2:21 PM   #2
mici
Programmer
 
Join Date: Oct 2004
Posts: 67
Rep Power: 5 mici is on a distinguished road
i can't see how... but you could use

label:
if() goto label;

to create a loop...
__________________
coffee is my heroin.
mici is offline   Reply With Quote
Old Oct 20th, 2004, 2:50 PM   #3
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
i assume that you can't use 'contine' with if statements but i mean something like this.....


if (arg = true)

{

do summing

arg++

continue

}

i know its pointless
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Oct 20th, 2004, 4:41 PM   #4
Daggerhex_Flynn
Programmer
 
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5 Daggerhex_Flynn is on a distinguished road
No, that won't work, you have to use goto or else a one of the three loops:
while ( ... ) {}
do { } while();
for ( ; ; ; ) {}
Daggerhex_Flynn is offline   Reply With Quote
Old Oct 20th, 2004, 5:12 PM   #5
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Nope... thoug if is a control statement, it is not a control loop.

continue only works with control loops. You could use labels but why bother? Just use a while statement instead, since a while is really an if in loop form. You can than you continue and break to control your program flow inside the while statement.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Oct 20th, 2004, 5:46 PM   #6
Daggerhex_Flynn
Programmer
 
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5 Daggerhex_Flynn is on a distinguished road
I think that you are looking for the same behavior as:

do {
...
}while( ... );
Daggerhex_Flynn is offline   Reply With Quote
Old Oct 20th, 2004, 8:43 PM   #7
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
I know what they all do, it was just something that came to me while I was sitting on the loo. Dunno why?
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Oct 21st, 2004, 12:54 AM   #8
Das Bruce
Newbie
 
Join Date: Oct 2004
Posts: 10
Rep Power: 0 Das Bruce is on a distinguished road
"goto" is the work of the devil, never ever use it in your code.
Das Bruce is offline   Reply With Quote
Old Oct 21st, 2004, 3:45 AM   #9
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
see another goto hater

disecting goto code is just wrong and should never have to be done.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Oct 21st, 2004, 8:52 AM   #10
mici
Programmer
 
Join Date: Oct 2004
Posts: 67
Rep Power: 5 mici is on a distinguished road
here we go again...
It's not gotos fault your code is unreadable, it's your fault...
__________________
coffee is my heroin.
mici is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC