random numbers in C

Posted by Sergey on Stack Overflow See other posts from Stack Overflow or by Sergey
Published on 2010-03-15T18:21:57Z Indexed on 2010/03/15 18:29 UTC
Read the original article Hit count: 374

Filed under:
for(i = 0; i < n; i++){
        srand(time(NULL));
        printf("%d ", time(NULL));
        for(j = 0; j < (n-1); j++){
            a[i,j] = rand();
        }
    }

I try to generate random numbers, but they are the same... I try srand(i * time(NULL)). No matter.. What should i do?

© Stack Overflow or respective owner

Related posts about c