Try setting your for loop up like this...
CODE
for (unsigned i = 0; i < toss; i++)
{
// Compare the return value against zero.
if (getFlip() == 0)
tails++;
else
heads++;
}
Notice how I use the result of the function call and compare. The problem you had was that you were not comparing the result of your method and instead just incrementing tails once, then heads the rest of the time (since after incrementing it once, tails no longer equaled zero).
This should function as you wanted.
Edit: Oh and I wanted to let you know that you should be using return types and not just "unsigned". You are probably getting some warnings because of this. Try using
int or if you want
unsigned int.
Enjoy!
This post has been edited by Martyr2: 16 Oct, 2007 - 09:41 PM