Final Project with Arrays

Hi, everyone! I have a final project in my computer science class. It's a simulated game in which you get eleven random letters, each from A-G, and you start on the middle letter. Then you have to essentially choose to travel either left or right, and then once you've traveled you have to choose to either "pick up" the letter at that spot or to leave it there. It keeps going until you pick up three of the same letter in a row (or until you run out of letters to pick up.)

For now, I'm just having trouble getting the exact same random letter list to stay. I can generate 11 random letters, but I don't know how to KEEP those same 11 letters throughout the entire game.

1
2
3
4
5
6
7
8
srand(time(0));
char randomLetter;

for (int i=0; i<11; i++)
{
  randLetter='A'+rand()%7;
  cout << randLetter;
}


This generates something like, for example, EFABGGEFDEB. But my problem is keeping EFABGGEFDEB in the loop for the duration of the game. How would I do that?

Thanks!
Save the letters in a char array.
You can save them in a string or vector.
Topic archived. No new replies allowed.