Read two text files into arrays and query the arrays for boy and girl names

LANGUAGE: C++

CHALLENGE:

Read in boynames.txt and girlnames.txt into separate arrays and search by the user entered boy name or girl name. The most popular names are listed first and the least popular names are listed last. write a program that allows the user to input a name. The program should then read from the file and search for a matching name among the girls and boys then store this information in an array. If a match is found, it should output the rank of the name. The program should also indicate if there is no match.

SOLUTION:



#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>

using namespace std;

int main(){
    //ifstream in_put;
    std::string enter_name;
    char data;
	int index = 0, count = 0;
	bool isFoundB = false;
	bool isFoundG = false;

	string boynames[1000][2];
	string girlnames[1000][2];

	count = 0;
	ifstream fileb("boynames.txt");
	while (count < 1000 && fileb.is_open()){
		fileb >> boynames[count][0];
		fileb >> boynames[count][1];
		count++;
	}

	count = 0;
	ifstream fileg("girlnames.txt");
	while (count < 1000 && fileg.is_open()){
		fileg >> girlnames[count][0];
		fileg >> girlnames[count][1];
		count++;
	}

    cout << "Enter the first name that you would like to find the popularity of.\n"
         << "Be sure to capitalize the first letter of the name.\n";
    cin >> enter_name;

	count = 0;
	while(count < 1000){
		if (boynames[count][0] == enter_name){
			cout << boynames[count][0] << " is ranked " << count << " among boys with " << boynames[count][1] << " namings" << endl;
			isFoundB = true;
		}

		if (girlnames[count][0] == enter_name){
			cout << girlnames[count][0] << " is ranked " << count << " among girls with " << girlnames[count][1] << " namings" << endl;
			isFoundG = true;
		}

		count++;
	}

	if(isFoundB == false){
		cout << enter_name << " is not ranked among the top 1000 boy names." << endl;
	}

	if(isFoundG == false){
		cout << enter_name << " is not ranked among the top 1000 girl names." << endl;
	}

    system("Pause");

    return 0;

}