I have a rand number generator. Now my question is how do I get for instance the first/second/third/fourth digit of the generated random number. Implementing this so the user can use a hint when guessing the number.
ex: result: 1234
hint 1: second number 2
hint 2: fourth number 4
Whats the best way to tackle this? I've been thinking to convert the string to an char array but that won't work I guess.
Correct me if my way of asking this questions is very bold.
int nummer = 4;
std :: string result = "";
for (int i = 0; i < nummer; i++)
{
result.push_back(rand()%10 + '0');
}
Aucun commentaire:
Enregistrer un commentaire