Note:不要使用
rand()
作为安全保护.如果你需要一个加密的安全号码,可以 Select see this answer.
#include <time.h>
#include <stdlib.h>
srand(time(NULL)); // Initialization, should only be called once.
int r = rand(); // Returns a pseudo-random integer between 0 and RAND_MAX.
在Linux上,您可能更喜欢使用random and srandom.