Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1057291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:50:41+00:00 2026-05-16T17:50:41+00:00

i’m having a problem using stricmp in a specific function, in other functions it

  • 0

i’m having a problem using stricmp in a specific function, in other functions it works perfectly, except this one.
the problem is that even if it compares the same string (char*) it doesn’t return 0.
what might be the problem?
(sorry for the mess, i’ll try formatting it)
that’s the code:

Employee* CityCouncil::FindEmp(list<Employee*> *lst, char* id)  
{  
 bool continue1 = true;  
 Employee* tmp= NULL;  
 char* tmpId = NULL, *tmpId2 = NULL;  
 list<Employee*>::iterator iter = lst->begin();  
 if ((id == NULL) || (lst->empty()==true))  
  return NULL;  
 while ((iter != lst->end()) && (continue1)){  
  tmp = (Employee*)(*iter);  
  tmpId = (*tmp).GetId();  
  if(tmpId != NULL)  
  {  
      if(stricmp(tmpId,id) == 0)  
       continue1 = false;  
  }  
  if (continue1 == true)  
  iter++;  
 }  
 if (iter == lst->end())
     return NULL;
 return (Employee*)(*iter);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:50:42+00:00Added an answer on May 16, 2026 at 5:50 pm

    Never blame a function that belongs to the C library. stricmp surely works as expected, meaning the strings are really different. There must be something wrong with the logic in this function – you should use printf statements to find out where and why the strings differ.

    EDIT: I put together a simple test program. This works for me:

    #include <stdio.h>
    #include <list>
    using namespace std;
    
    // Dummy
    class Employee
    {
        public:
            Employee(const char *n){ id = strdup(n); }
            char *id;
            char *GetId() { return this->id; }
    };
    
    Employee* FindEmp(list<Employee*> *lst, char* id)
    {
        bool continue1 = true;
        Employee *tmp = NULL;
        char* tmpId = NULL;
    
        list<Employee*>::iterator iter = lst->begin();
        if(id == NULL || lst->empty())
            return NULL;
    
        while(iter != lst->end() && continue1)
        {
            tmp = (Employee*)(*iter);
            tmpId = (*tmp).GetId();
            if(tmpId != NULL)
            {
                if(stricmp(tmpId,id) == 0)
                    continue1 = false;
            }
            if(continue1 == true)
                iter++;
        }
    
        if(iter == lst->end())
            return NULL;
    
        return (Employee*)(*iter);
    }
    
    
    int main(int argc, char **argv)
    {
        list<Employee*> l;
    
        l.push_back(new Employee("Dave"));
        l.push_back(new Employee("Andy"));
        l.push_back(new Employee("Snoopie"));
    
        printf("%s found\n", FindEmp(&l, "dave")->GetId());
        printf("%s found\n", FindEmp(&l, "andy")->GetId());
        printf("%s found\n", FindEmp(&l, "SnoOpiE")->GetId());
    
        return 0;
    }
    

    Note that I used the function you provided. Again, there is nothing wrong with stricmp, the problem must be in your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I'm making a simple page using Google Maps API 3. My first. One marker
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.