hey

im new on this site and im taking c++ for video game design
and the assignment we're working on a program that asks you how many fav. games you have and what their names are

and it will output the names and number of games you entered
this is what i have so far

#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {

// number of games
cout << " Enter Number of Fav. games: ";
string Number;
cin >> Number;
int n = atoi(Number.c_str());
vector<string> GameList;
string x;
while (n > 0) {

cout << "gameList";
cin >> x;
GameList.push_back(x);
n--;
}

but im not sure how to make the output part if u could help it would be appreciated
You are missing an ending } for main, but I'm guessing that's just a copy/paste error.

Btw, use code tags next time:
http://www.cplusplus.com/articles/firedraco1/

Anyway, you would use a for loop for that. Look up std::vector's .size() member and it's operator [] (aka subscript operator) in this site's reference section.
Here's your Code finished.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main()
{
	vector<string> games;
	string faves;
	string game;
	cout << "How Many Favorite Games Do You Have?\n";
	cin >> faves;
	int i = atoi(faves.c_str());
	
	while(i>0)
	{

		cout << "\nPlease Enter game names " << i << " :";
		cin >> game;
		games.push_back(game);

		i--;
	}

	cout << "Your Favorite Games Are: " << endl;

	int g = 0;
	while(games.size() > g)
	{
		cout <<g+1<<" "<< games[g]<< endl;
		g++;
}
	cout << endl;
}
@vection: You shouldn't just post answers. It doesn't help the OP learn at all.
@firedraco: sorry, we're in the same class, I was just helping him with it in class cuz i was having problems with it yesterday..
Sigh. Why would you post a complete answer (it's not exactly an optimal answer, and like firedraco said, doesn't help OP either).

Are you two on the same course or something? You've both asked exactly the same question.
It doesn't really matter. We don't care how you help him in class, but this is a forum, and in here, the way it works is that you don't post the answer. You post hints and tips in the right direction to the answer. If you already had the solution you could take the material you learned from it and direct the OP towards it.
Well I am sorry.
Topic archived. No new replies allowed.