i have made a queue using STL. the queue contains strings only. how to check for a particular string if it present in queue or not?

Recommended Answers

what STL container did you use?

Jump to Post

You don't use strcmp with std::string, instead std::string has == operator that returns true if the two strings are equal, false otherwise. for example

std::string s = "Hello";
if( s == "HELLO" )
{

}
Jump to Post

All 5 Replies

what STL container did you use?

actually i m using strcmp function for ccomparing which is giving type mismatch error.
so i did this : queue<char*> myqueue .
earlier it was: queue<string> myqueue

now the error has gone and code works fine but i didnot understand what does queue<char*> myqueue means?
what type value the queue have?

and sorry for the late reply.

You don't use strcmp with std::string, instead std::string has == operator that returns true if the two strings are equal, false otherwise. for example

std::string s = "Hello";
if( s == "HELLO" )
{

}

ok..it works.
but what does queue<char*> myqueue means?

The contents of the queue are char*, you can't mix it with std::string

Be a part of the DaniWeb community

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