jeudi 23 février 2017

Random number between more ranges (ascii) [duplicate]

This question already has an answer here:

I need to generate 10 passwords(geslo) which include small or big characters or numbers. Like this:

passwords

I have this so far:

#include <iostream>
#include <cstdlib>
using namespace std;

int main() {
    for(int i=0; i<10; i++){


        int x = rand() % 4 + 6;

        string geslo;

        for(int j=0;j<x; j++){

            int y = rand() % 9 + 48;
            char q = (char) y;
            geslo+=q;
        }

        cout << "geslo " << i+1 << ": " << geslo << endl;
    }
    return 0;
}

This generates just numbers, and I don't know how to make it so that it will also generate small and big characters (different ascii ranges)




Aucun commentaire:

Enregistrer un commentaire