c - How to generate Random number of 12 bytes? -
i'm working on project on linux in c , in need generate random number of 12 bytes. have searched on net couldn't find other srand or random function. these functions can generate random number of 32-bit(4 byte).
i'm looking generating random number of 12 byte.
does know library on linux provide functionality ?
ok solution:
unsigned char buf[12]; int i; srand(time(null)); (i = 0; < sizeof(buf); i++) { buf[i] = rand() % 256; }
(yes, i'm using modulo - if care uniform distribution, don't utilize it.)
c linux
No comments:
Post a Comment