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.
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.
Hope is the first step on the road to disappointment.
Think ya need to add 1 to that:
char foo = 'A' + rand() % (1 + 'F' - 'A');
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
Right you are. That'll teach me to talk and type at the same time.Originally posted by Zach L.
Think ya need to add 1 to that:
char foo = 'A' + rand() % (1 + 'F' - 'A');
Quzah.
Hope is the first step on the road to disappointment.
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.Originally posted by Salem
How aboutCode:"ABCDEF"[rand()%6];