Generating a random, uniformly distributed real number in C
<p>I would like to generate a random, real number in the interval [0,1].
I would like to set a pointer, say <code>n</code>, for the number so whenever I stated <code>n</code>, it will be referred to the random generated number.</p>

<p>I have searched on StackOverflow and on Google, but most of them are for C++ or for integers.</p>

<p>I have tried this code suggested to me in the answers:</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
int main()
{
 double n;
double get_random() { return (double)rand() / (double)RAND_MAX; }
n = get_random();
printf("%f", n);
   return 0;
}
</code></pre>

<p>However, I can only get a value 0.00000000. </p>

<p>How could I fix my program?</p>