when i try to compile this it says random undeclaredCode:#include <stdio.h> #include <stdlib.h> int main() { long int hat; hat = random(); /*use rand() for short ints*/ printf("%d is a random number.\n",hat); return(0); }
thanks
-ytaipsw
when i try to compile this it says random undeclaredCode:#include <stdio.h> #include <stdlib.h> int main() { long int hat; hat = random(); /*use rand() for short ints*/ printf("%d is a random number.\n",hat); return(0); }
thanks
-ytaipsw
The function is actually rand(), and you need to seed it first with srand(). There are details on the crpogramming.com site, or you can search the web.
The function random is nonstandard, so it appears you are using code with a compiler that does not have support for that code. Use the standard rand, or tell us more specific details about your needs.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*