loop not exiting

Joined
May 17, 2008
Messages
3
Reaction score
0
Can anybody tell me why
Code:
for(i; currComb & (1 << i) != 0; i++);
remains looping indefinetly?

i == 0 in the beginning, I have checked it (I also initialized it to 0, same story)
currComb == 1
and currComb & (1 << i) == 0 after the first iteration

I am using gcc
 
Joined
May 17, 2008
Messages
3
Reaction score
0
Found the reason for the problem. If you have an expression that you want to compare against a value or variable, then the expression has to be in quotes. In my case, "(1 << i) != 0" was evaluated and the result was TRUE every single time.
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top