Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef RANDOM_CHARACTER_H
- #define RANDOM_CHARACTER_H
- #include <cstdlib>
- using namespace std;
- char getRandomCharacter(char ch1, char ch2)
- {
- return static_cast<char>(ch1 + rand() % (ch2 - ch1 + 1));
- }
- char getRandomLowerCaseLetter()
- {
- return getRandomCharacter('a', 'z');
- }
- char getRandomUpperCaseLetter()
- {
- return getRandomCharacter('A', 'Z');
- }
- char getRandomDigitCharacter()
- {
- return getRandomCharacter('0', '9');
- }
- char getRandomCharacter()
- {
- return getRandomCharacter(0, 127);
- }
- #endif
Add Comment
Please, Sign In to add comment