i am need help

I am constructing a program that randomly determines whom the user should send a text message to. Allow the user to enter five friends that will be used for the selection.

But it asks the user for a seed at the beginning but that doesn't determine how many names the user is allowed to put in.

This is where i am at right now

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

int main()
{
string num_friends[5];
int user_input;


cout << "== Who Should I Text? ==" << endl;
cout << "Enter seed" << endl;
cin >> user_input;

for (int counter = 0; counter < user_input; counter++)
{
cout << "Enter friend " << counter << endl;
cin >> num_friends[counter];
}



}

this is an example of what i need to have done

21
Adam
Bill
Cat
Damion
Edward

Program Output

== Who Should I Text? ==
Enter seed
Enter friend 0
Enter friend 1
Enter friend 2
Enter friend 3
Enter friend 4
You should text: Cat
These other friends didn't make the cut:
Adam
Bill
Damion
Edward

this is an example of what im trying to accomplish.
but the number that the user puts in at the beggining does not do anything im not sure how to code it the right way

Last edited on
Can you Elaborate what do you exactly wana do.
Last edited on
21
Adam
Bill
Cat
Damion
Edward

Program Output

== Who Should I Text? ==
Enter seed
Enter friend 0
Enter friend 1
Enter friend 2
Enter friend 3
Enter friend 4
You should text: Cat
These other friends didn't make the cut:
Adam
Bill
Damion
Edward

this is an example of what im trying to accomplish.
but the number that the user puts in at the beggining does not do anything im not sure how to code it the right way
closed account (DEUX92yv)
The user always enters 5 friends, right? So use for (int counter = 0; counter < 5; counter++).

Then you should have a 5-element array of strings for the friend names (you already do have this, but it's named incorrectly: 'num_friends' shouldn't be a string, and it should just be called 'friends' or 'friend_names' so that its name represents what it actually is).

The random seed you're talking about comes after the user has entered all five names. You can let the user enter a seed, then seed the random number generator with that, if you'd like. See http://www.cplusplus.com/reference/cstdlib/rand/ for some help with that.
Last edited on
Topic archived. No new replies allowed.