
-----------------------------------
jamonathin
Thu May 05, 2005 8:59 am

How to Loop?
-----------------------------------
How can you run just a basic loop?  What I'm trying to do is make this program (http://www.compsci.ca/v2/viewtopic.php?t=8675) and I can do everything, but loop.  Any suggestions?  :)

-----------------------------------
rdrake
Thu May 05, 2005 11:10 am


-----------------------------------
If you're using C, something like
while (1)
{
  // code goes here
}should work.

If you're trying to make a for loop, then
int i;

for (i=0;i> i;
   
   if (i == 53)
   {
      break;
   }
}

-----------------------------------
jamonathin
Fri May 06, 2005 1:20 pm


-----------------------------------
sweet, thanks man.  :)

-----------------------------------
MysticVegeta
Mon Jun 20, 2005 8:04 am


-----------------------------------
I came across a C++ book and another way to infinite loop is ->
for (; ;){
//code here
}


I think it works

-----------------------------------
1of42
Mon Jun 20, 2005 7:22 pm


-----------------------------------
Or, to be cute...


#define EVER ;;

for(EVER)
{
}


-----------------------------------
wtd
Tue Jun 21, 2005 2:19 am


-----------------------------------
Being cute in such languages isn't cute.

-----------------------------------
1of42
Tue Jun 21, 2005 11:34 am


-----------------------------------
Well, you could just go spoil ALL my fun... *pouts* ;)

-----------------------------------
wtd
Tue Jun 21, 2005 12:09 pm


-----------------------------------
Well, you could just go spoil ALL my fun... *pouts* ;)

The problem is that some student will come in here, see that, and consider it the best way to loop.

-----------------------------------
MysticVegeta
Tue Jun 21, 2005 4:05 pm


-----------------------------------

The problem is that some student will come in here, see that, and consider it the best way to loop.... and his teacher will cut his mark for redundant code, illegal use of vars and not following instructions, and if you have a teacher like ours, dam someone is in deep s**t

-----------------------------------
1of42
Tue Jun 21, 2005 5:58 pm


-----------------------------------
illegal use of vars

s'not a var, just a text substitution :roll:

-----------------------------------
Cinjection
Wed Jun 22, 2005 5:51 pm


-----------------------------------
Programming's an art, NOT a science. This is very debatable, but that's my opinion. If you find a creative or fun way of doing something, you shouldn't be penalised for it. As long as it's not really bad coding style....like goto or something. I ALWAYS make my first for loop var 'c' so i can go:


for(int c = 0;c 