I need a way of making a name unique (i.e. making it a unique ID) but still retaining some features of the name to make it recognisable. The code below works by appendix a random suffix to the name:
As Salem says, some kind of incrementing integer is a pretty common way. Make it static so that the value is retained between calls to the function, and you can also make it atomic if you need different threads to be able to make use it. Something like:
If you worry about going all the way round the numbers and repeating, well, if you use a 64 bit value and you do a billion a second, you'll die long before you run out of numbers and it won't be your problem anymore.