Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- const int MAX_PLAYERS = 2;
- int choice = 0;
- // pointing to array on the heap
- string* playerList = new string[MAX_PLAYERS];
- // enter player names in playerList
- for (int i = 0; i < MAX_PLAYERS; i++)
- {
- cout << "Enter player's name..." << endl;
- getline(cin, playerList[i]);
- system("cls");
- }
- // display list of players
- for (int i = 0; i < MAX_PLAYERS; i++)
- {
- cout << playerList[i] << endl;
- }
- // Main Menu
- while (playerList)
- {
- cout << "Do you want to drop player from list?" << endl;
- cout << "1.Yes" << endl;
- cout << "2. No" << endl;
- cin >> choice;
- system("cls");
- if (choice == 1)
- {
- cout << "Which name would you like to delete?" << endl;
- cout << "1. " << playerList[0] << endl;
- cout << "2. " << playerList[1] << endl;
- cin >> choice;
- if (choice == 1)
- {
- delete[0] playerList;
- }
- // check if slots are empty
- for (int i = 0; i < MAX_PLAYERS; i++)
- {
- if(!playerList[0])
- cout << "empty slot" << endl;
- }
- }
- if (choice == 2)
- {
- cout << "goodbye" << endl;
- playerList = nullptr;
- }
- if ((choice != 1) || (choice != 2))
- {
- }
- }
- delete[] playerList;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment