Okay problem in C++
I have written data to a text file using ofstream with the format
name#address#phone#date#
In the text file there are multiple lines of this format.
What is the best way for me to search the file by any of the strings (i'll use date for this example)
and then output that line with proper formatting.
At the moment, i'm just trying to output the line and i was thinking something along the lines of:
void searchDate()
{
char dateSearch[9];
size_t i;
string line;
cout <<"Enter a date you wish to search by: \n";
cin.getline(dateSearch, 9);
ifstream bookcopy ("bookcopy.txt.", ios::in);
while(getline(bookcopy,line))
i = line.find(dateSearch);
if (line.compare(dateSearch) != 0)
cout << "result " << line << endl;
return;
}
But that is not working...