Hello, I've basically completed my homework exercise for class but i'm stuck with the random number generator. When executed the program will generator random numbers but when exited and opened again the same "random numbers" appear in the same order. I've looked through my notes and can't find any solutions so hints or answer /w logic (if that makes any sense) would be much appreciative.
Exercise:
Make a: roll(), setFaceValue(val), getFaceValue() and display().
roll() sets the faceValue to a random number between 1 and 6.
setFaceValue(val) sets the faceValue to the value of val
getFaceValue() returns the current faceValue
display() prints a string representation on the console.
Didn't knew about srand(time(NULL)) so im going to do a little research about srand(0) vs srand(time(NULL)) . I've always been using srand(0) from day 1 of the class.
srand(0) will always start the random sequence at index 0. rand() increments to the next number in the sequence. It's not real random, it's a sequence of numbers that appears to be random. If you keep generating numbers for long enough you will see a pattern which is different for each compiler/implementation. The pattern will emerge no matter what seed you use.