Creating Random hex numbers

This is a discussion on Creating Random hex numbers within the C++ Programming forums, part of the General Programming Boards category; I'm trying to create a random product ID for a project I'm developing. I'm just looking to create some random ...

Creating Random hex numbers

I'm trying to create a random product ID for a project I'm developing. I'm just looking to create some random hex values. However, I noticed that when I used %x with rand(), it generated 8 digit hex values when I know the maximum value of rand() is 32767.

Even if the rand was good - the output cannot be named GUID... GUID creation algorithm uses some data about creation date, computer hardware and maybe something else to ensure the uniqueness of the return value during the Universe life... So the algorithm using only some pseudo-random generator will be wrong in any case, because it cannot guarantee such a uniqueness