How to pick a random number in C.
Arabica (3)

If you want a guess a number game, (to the ten thousands). Then this post is for you! This relies on an asm() command called "rdtsc". Which is used for random numbers or time (shift eax to the left 32 times to do this). Here is the function:

unsigned short rand() {
 unsigned short c; // We are going to set the value of eax to c after "rdtsc"
 __asm__("rdtsc\n" : "=a" (c));
 return c;

That is it!

You are viewing a single comment. View All
wynnepaton (3)


A really stupid question here!

Does any of the code specify the range of the random number generated?