#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void generateHex(char *hexStr, int length) {
const char hexChars[] = "0123456789ABCDEF";
for (int i = 0; i < length; ++i) {
hexStr[i] = hexChars[rand() % 16];
}
hexStr[length] = '\0'; // Null-terminate the string
}
int main() {
srand((unsigned int)time(NULL)); // Seed the random number generator
int length = 8;
char hexNumber[9]; // 8 characters + null terminator
generateHex(hexNumber, length);
printf("Random Hexadecimal Number: %s\n", hexNumber);
return 0;
}
/*
run:
Random Hexadecimal Number: 3E275186
*/