programming-examples/c/Numerical/C Program to Generate Random Hexadecimal Bytes.c
2019-11-15 12:59:38 +01:00

19 lines
405 B
C

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int length;
char str[] = "0123456789ABCDEF";
/* Seed number for rand() */
srand((unsigned int) time(0) + getpid());
length = rand() % 15 + 8;
while(length--)
{
putchar(str[rand() % 16]);
srand(rand());
}
printf("\n");
return EXIT_SUCCESS;
}