Possible Duplicate:
why do i always get the same sequence of random numbers with rand()?
I am confounded by the fact that even using different programs (on the same machine) to run /compile, and after nilling the vaues (before and after) the function.. that NO MATTER WHAT.. I'll keep getting the SAME "random" numbers… each and every time I run it. I swear this is NOT how it's supposed to work.. I'm going to illustrate as simply as is possible…
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
    int rPrimitive = 0;  rPrimitive = 1 + rand() % 50;
    NSNumber *rObject = nil; rObject = [NSNumber numberWithInt:rand() % 10];
    NSLog(@"%i  %@", rPrimitive, rObject);
    rPrimitive = 0;   rObject = nil;
    NSLog(@"%i  %@", rPrimitive, rObject);
    return 0;           
}
Run it in TextMate:
i686-apple-darwin11-llvm-gcc-4.2
8  9
0  (null)
Run it in CodeRunner:
i686-apple-darwin11-llvm-gcc-4.2
8  9
0  (null)
Run it a million times, if you'd like. You can gues what it will always be. Why does this happen? Why oh why is this "how it is"?
 
     
     
     
    