How may I get a random character from A to F?
I've tried static_cast<char>(65 + rand() % 70) and it doesn't works.
Printable View
How may I get a random character from A to F?
I've tried static_cast<char>(65 + rand() % 70) and it doesn't works.
char foo = 'A' + rand() % ('F'-'A');
Quzah.
Think ya need to add 1 to that:
char foo = 'A' + rand() % (1 + 'F' - 'A');
Right you are. That'll teach me to talk and type at the same time. :DQuote:
Originally posted by Zach L.
Think ya need to add 1 to that:
char foo = 'A' + rand() % (1 + 'F' - 'A');
Quzah.
Amazing, thanks. Never thought about doing random stuff like that. In fact, you can place whatever you want in that string and it'll work. :pQuote:
Originally posted by Salem
How about;)Code:"ABCDEF"[rand()%6];