# Thread: Infinite While Loops Question

1. ## Infinite While Loops Question

I am learning C++ and I was under the impression if you were to do an infinite while loop to do

Code:
```int counter=0

while(1)
{
counter++;
if(counter>10)
{
break;
}
}```
However, my book says to use while(true)...I did learn the while(1) method in C programming, is "true" a new feature since it is apart of c++? Which should I use to fit among the norm?

2. true is the same as 1, and false is 0,

but for infinnite loops id jsut do

Code:
```for( ; ; )
{
//do stuff here
if(/*something*/)
{
break;
}
}```

3. >> true is the same as 1, and false is 0,

You could see it like that, but I'd advise you not to.

Don't think of true and false as being 1 and 0. Try to think of true and false as absolute values.

In C, a negative number would also equate to true in a loop condition, eg.
Code:
```while (-3)
{
//...
}```
So true could be a negative or a positive, but not zero. Java is strict about this, in that a loop condition must equate to either true or false.

4. yea i was thinking in terms of just 1 and 0's
but 0 is always false, so anything other then 0 would be true.
besides i didnt say true was only 1, i just said that true is the
same as 1. just to help him understand, if id of went on
with a rant about all the things it could be he could of gotten
lost, and it strayed from his question.

5. No biggy, I was just trying to explain the reason for having the value true and false in a language.

A strongly typed language would enforce a boolean value as a loop condition rather than allowing any value.

I know you didn't mean that true is only 1, I just did want 'hern' to think of it like that.