I'm only seeding rand() once, yet I have a sort of odd problem... When I do,
int r = rand() % 7 + 1;
it returns 4 every time.
But if I replace that 7 with any other number, it works just fine.
Any idea why this is happening?
My full code's all cluttered right now, but here's basically what's giving me the problem:
int main()
{
srand(time(0));
int r = rand() % 7 + 1;
cout << r;
}
Even when I run it just like this, with nothing else, it still only returns 4.
P/S: For a little context, I'm working on a super simple amazons solitaire game that runs in the console (yes, I'm aware that console games aren't ideal. I just needed a simple amazons solitaire game I can play on my computer for whenever I don't have a deck of cards around.) which is why the random number has to be between 1 and 7.
PP/S: I'm using Xcode.