hey, I was wondering if i could get some help. I have this so far. I don't want to use an array or vector.
Code:
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
string boy, girl, name, next;
char symbol;
ifstream infile;
int rank;
infile.open("babynames2004.txt");
if(infile.fail()){
cout << "Error: File opening failed." << endl;
exit(1);
}
infile >> rank >> boy >> girl >> symbol;
//is there any way to loop this so it goes all the way to the end of the file?
cout << "Enter a name to see how popular it is." << endl
<< "Please capitalize the name." << endl;
cin >> name;
if ( name == boy){
cout << name << " is ranked " << rank << " in popularity among boys." << endl;
}
else if (name == girl){
cout << girl << " is ranked " << rank << " in popularity among girls." << endl;
}
else{
cout << name << " is not ranked among the top 1000 boy or girl names." << endl;
}
infile.close();
return 0;
}