An efficient way to create random numbers in C/C++ is rand()
function. but I've seen code like this to create random variables:
int x; x%=100;
Is this a good way to produce a simple random number? If your answer is no, please tell me why?
EDIT : well the actual code is here:
int temp1,temp2;
A=(abs(temp1))%11-1;
B=(abs(temp2))%11-1; //Randomize without using rand()
A friend of mine wrote this code. I tried to compile it and I got uninitialized local variable 'temp1' used
error (on MSVS). He wrote this code in 2011 and it worked on his Linux with latest version of GCC.