i = (int) genrand_int32();
int main(int argc, char **argv)
int m = getRandomNum();
printf("m = %d", m);
The Mersenne Twister is not magical; it has no way of producing random results from predictable input. If you want a random sequence, you have to seed the generator by calling
init_genrand() with some sort of unique value. Otherwise it'll use a fixed default seed (specifically: 5489).
An easy value to use is the current time:
Don't call this more than once during your program, though -- otherwise, you'll restart the sequence!