LINUX - 随机数
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <regex.h> int main(){ int iRandTmp=-1; int i = 0; iRandTmp = open("/dev/urandom", O_RDONLY); printf("first:%d\n\n\n\n\n\n",iRandTmp%65536); close(iRandTmp); int fd=0; char *buff=NULL; unsigned long ulTest = 0; int ulSeed; fd=open("/dev/urandom",O_RDONLY); read(fd,&ulSeed,sizeof(ulTest)); printf("second:%u",ulTest%400); close(fd); return 0; }