Hi, Its Dilyan again. Now I want to make a simple console program wich makes
complex passwords. I have an Idea how It will work, but don't know how to write it down.
The user first must input his name or a word and then the PC must put a random number after the first 3 letters (from 0 to 49), then he must take the last 2 letters and then replace them with a random letter (from B to W). After that he must replace the middle 1 letter with a random number (23 to 78).
After that he must type the created character string on the screen.
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <string>
usingnamespace std;
string get_random_number_string( int min, int max )
{
int num;
num = (rand() %(max -min +1)) +min;
ostringstream result;
result << num;
return result.str();
}
int main()
{
// initialize the random number generator
srand( time( NULL ) );
cout << "A random number in 0..49: " << get_random_number_string( 0, 49 ) << endl;
cout << "A random number in 23..78: " << get_random_number_string( 23, 78 ) << endl;
return 0;
}
Thats realy nice Duoas! Your program works, and I looked at the STRING tutorials you gave me the link for, I sellected the Insert operator, but I didn't saw a command which puts random nums or letters in the half of the inputted from the user string. But any way you helped me alot.
Thanks.