Im trying to create a function that searches my array for a specific string, and then displays that string and the other content associated with it. I'm basically searching for a keyword within an array that has multiple strings with in each element. If that makes sense?
This is what i have so far for the function. What my program does is that it grabs a weblog file that has ip address, the date the website was accessed, and the website name, and it stores that information in each element of a dynamic array. What i want this function to do is take in an ip address, search the array for the specific ip address, and then show all that matched with that ip address.
void weblog::lineSearch(std::string key)
{
std::cout << "Here are the items that match your search: " << std::endl;
for(int i = 0; i < size(); i++)
{
It's a very bad idea to have an array structured like that. Instead, you should make a class/struct to store your data, and then have the array contain instances of that class/struct instead.
I wish i could, but this is what was instructed by my teacher. I figured it out though, but now I have ran into another problem and maybe you could help me: at the end of my program, when it runs, the program breaks with an error.
Heres the error message:
Unhandled exception at 0x00C388B6 in Project 2.exe: 0xC0000005: Access violation reading location 0x01463000.
I think its because my array is exceeding its boundaries.
Here is what my function looks like now:
void weblog::lineSearch(std::string key)
{
std::string ip;
int length = key.length();
bool IsIpSame = false;
int i = 0;
std::cout << "Here are the items that match your search: " << std::endl;