Hi guys, I am trying to write a program that will ask for users name, birthdate and pet and from those info I need to use a random number generator to select 6 char from the name and animal and 2 numbers from the birthdate. This is my code to far.
using namespace std;
// **************************
//
// Purpose of this program is to
// ask the user there name,favorite animal
// and birthday and generate a password
// base off of that
// **************************
int main () {
const int MAX = 100;
char name[MAX];
char birth[MAX];
char pet[MAX];
int password;
srand(time(0));
password = rand() % 7;
cout <<"Please enter your name :";
cin>>name;
cout <<"Please enter your birthday :";
cin>>birth;
cout <<"Please enter your favorite pet/animal :";
cin>>pet;
cout <<" password: ", password << '\n';
First, the line cout <<" password: ", password << '\n'; isn't going to work like you want.
Second, why is your password variable an integer? Surely if you want the password to be a combination of data you're retrieving from strings then it needs to be a string itself.
Third, is there any reason you're using C style strings, rather than the string class?