Strange behaviour of rand() in Xcode
问题 While using Apple Xcode, the C program I include below will always return a 5 for y but z will return a random number, even though they have the same expression. Can you identify a reason for this behaviour? #include <stdio.h> #include <time.h> #include <stdlib.h> int main() { int x,y,z; srand((unsigned int)time(NULL)); x = ((unsigned int)time(NULL)); y=((double)rand()/(double)(RAND_MAX)*10); z=((double)rand()/(double)(RAND_MAX)*10); printf("Time %d\n", x); printf("\n"); printf("Number y %d\n