the device named ``random"

#include 
#include
#include
#include

#include


int
main(void)
{

int i,j,randomfd;
int rand[100];

//for(i=0;i<10;i++)

//{

//srand(time(NULL)+getpid());

// printf("%d ",rand());


//} printf("\n");
randomfd=open("/dev/random",O_RDONLY);

if(!randomfd)
printf("open random device error\n");

for(i=0;i<100;i++)
{
read(randomfd,rand,10);
for(j=0;j<2;j++)
printf(" %d",rand[j]);
printf("\n");
}

}

No comments: