Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- void intro();
- int country_Array();
- int i = 0;
- std::string cName[100];
- std::string cCapital[100];
- int totalNumOfCountries;
- int main()
- {
- intro();
- country_Array();
- return 0;
- }
- void intro()
- {
- std::cout<< std::setw(5) << "Welcome to the Country Selector, please choose from one of the following countries and you will see all the states and capitals: " << std::endl;
- }
- int country_Array()
- {
- int countryChosen;
- std::string countryName;
- std::cout << std::setw(10) << "1. European, 2. Middle-Eastern, or 3.Asian country" << std::endl;
- std::cout << std::setw(10) << "Select the number you wish to see: ";
- std::cin >> countryChosen;
- switch (countryChosen)
- {
- case 1: countryName = "europeanData.txt";
- break;
- case 2: countryName = "middleEast.txt";
- break;
- case 3: countryName = "Asian.txt";
- break;
- }
- std::ifstream inFile;
- inFile.open(countryName);
- if(inFile.fail())
- {
- std::cout << "The country.txt file failed to open";
- exit(-1);
- }
- while (inFile)
- {
- inFile >> cName[i];
- inFile >> cCapital[i];
- i++;
- }
- return i-2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement