Code:
r=srand((unsigned)time(null));
NULL is uppercase, not lowercase.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int r;
r=srand((unsigned)time(null))%100;
printf("%d",r);
return(0);
}
That doesn't do what you think it does. Try this program instead:
Code:
#include <stdio.h> /* for printf() */
#include <stdlib.h> /* for rand(), srand() */
#include <time.h> /* for time() */
int main(void) {
int x;
srand((unsigned)time(0));
x = rand() % 100;
printf("You have a %i%% change of doing that.\n", x);
return 0;
}
See the FAQ, too, for more information.