I have been browsing the web for days now trying to find a solution to my problem and have yet to come up with anything so far so I figured I would ask some professionals.
Basically I need to read a text file which contains records along the lines of:
ClientNum LName FName
123456 XX YY
etc..
etc..
and then let the user input either a range of ClientNum's or one specific ClientNum and display all data for that one record. So far I have been using getline and have successfully displayed all records with a while loop but I cannot figure out the search function. By the way I need to use the BASICS of C++ so basically just loops. I will post my code for you to review and let me know if you can help out thanks!
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string getcontent;
string search;
cout << "Input: ";
cin >> search;
ifstream openfile ("TEST.txt");
if(openfile.is_open())
{
while(!openfile.eof())
{
getline (openfile,getcontent);//
cout << get content << endl; // these two lines alone in a while loop display ALL records
if(search == getcontent ) // this was my theory for searching records but does not display anything to the console
{
cout << getcontent << endl;
}
}
openfile.close();
}
else
{
cout << "File error\n";
break;
}
system("PAUSE");
return 0;
}