Ja bym zrobił coś takiego:
struct gameData{
string id;
string name;
string number; //lepiej zeby bylo np intem, unsigned intem
};
gameData gamesData[] = {
{"1", "Battlefield 1", "100"},
{"2", "WatchDogs 2", "120"},
{"3", "Grand Theft Auto 5", "80"},
{"4", "Black Desert Online", "50"},
{"5", "World of Warcraft", "50"},
{"6", "Eternal Magic", "50"},
{"7", "Ori and the Blind Forest", "170"},
{"8", "Resident Evil 3", "50"},
{"9", "Firewatch", "40"},
{"10", "The Wither 3", "50"},
{"11", "Cyberpunk 2077 (Preorder)", "199"},
{"12", "Disco Elysium", "150"},
{"13", "Fifa 2020", "160"},
{"14", "Rocket League", "50"},
{"15", "NBA 2k19", "40"},
{"16", "Car Mechanic Simulator", "50"},
{"17", "Farming Simulator 2020", "100"},
{"18", "Tank Mechanic Simulator", "30"},
};
for(int i = 0; i < sizeof(gamesData) / sizeof(gamesData); i++)
{
if(typeGamesId[i] == choice)
{
cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
}
}
Chociaż na to:
sizeof(gamesData) / sizeof(gamesData)
trzeba uważać czasem