senait.kifle.127 0 Newbie Poster

My Objective is to define a function, with a pointer to a list of elements of the structure I created as the first parameter, a C-character string (of type char * ) as the second parameter and one of the of the two values,num or name, from the above enumeration type as the third parameter.
In the body of this function, all elements of the complete list in the first parameter are to be checked whether -by calling the function the bool function isPartof and create a new list with all the hits(matches) found. Finally Return the head of this list as a function value.

I used std::search to easily determine if a string contains a specific substringin the bool function. here are segemnts of the code that I worked so far. Thanks a lot guys!

enum item{num,type};//enumeration type

//My structure 

struct liste{
    char *co;
    char *di;
    liste* next;
};

//bool function
bool isPartof(const char *key, const char *search)
{
    const char *searchEnd = search + std::strlen(search);
    return std::search(search, searchEnd, key, key + std::strlen(key)) != searchEnd;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.