Whats going on is an address book. There is a search function in the program that takes in a string for the phone number. The file is read and if the string exist, it file is reread and the characters infront of it are sent to output.... basically showing who the number belongs too... But.. I need help...
cout<<"Enter number: ";
getline(cin, q, '\n');
string line;
ifstream AB ("AddressBook.txt");
if (AB.is_open())
{
while (! AB.eof() )
{
getline (AB,line);
if (line == q){
cout << "Match Found!" << endl;
cout << "Number Belongs To: "<<endl;
cout<<endl;
char ch;
while (! AB.eof() )
{
ios_base::cur;
AB.get(ch);
cout<<ch;
while (! AB.eof() )
{
getline (AB,line);
if (line == q){break;}
}
}
Im sure its something simple, but I keep getting the first letter of the persons name in the txt of who the number belongs too.