Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <ctime>
- #include <string>
- std::string randomstring(int len) {
- srand((long)time(0));
- std::string s;
- for(int i=0; i<len; ++i) {
- int rand = rand() % 3;
- s.append(
- rand == 0 ?
- s = rand()%(90-65) + 65 //A-Z
- : rand == 1 ?
- s = rand()%(57-48) + 48 //0-9
- : rand()%(122-97)+97 //a-z
- );
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement