Hi all
I am trying to generate some numbers with the rand() function like below:
int main()
{
int i=0
for(i=0;i<20;i++)
{
printf("%f\n",rand_md());
}
return 0;
}
float rand_md()
{
return (float)rand()/(RAND_MAX+1.0);
}
But when I run gcc rand.c, I get the error like below: rand.c: In function ‘main’: rand.c:21: warning: format ‘%f’ expects type ‘double’, but argument 2 has type ‘int’ rand.c: At top level: rand.c:36: error: conflicting types for ‘rand_md’ rand.c:21: error: previous implicit declaration of ‘rand_md’ was here
What's wrong with my code?
Best Regards,