but I still win the first guess |
Are you confusing firstpeg, secondpeg, thirdpeg (why are these global?) and peg1, peg2, peg3?
As you're passing firstpeg, secondpeg, thirdpeg to checkcolours(), it seems you're comparing the guesses with themselves, rather than against the random colors (peg1, peg2, peg3.)
(Maybe renaming firstpeg, etc to guess1, etc would probably make things easier to follow? And changing a, b, c to clearer names definitely would. Variable names are important!)
And:
- colour isn't the only variable you need to 0 before use. As a general rule, you should initialize all variable before first use.
- and you should be calling srand() once at the start of a program, not every time you want a random number (see my following post.)
Andy
PS It might help if you up the warning level on your compiler!?