Ok, this is what I have been trying to do, please correct me if I am wrong I am trying to check if myarray contains the char abcd. What I am thinking of doing it this way:
char* myarray[] = {
"hello",
"wooorld",
"hi"};
if(myarray->Contains(abcd))
{
//do stuff
}
My question is, is there a better way of doing it?
One way do it is to use std::string
and std::vector
with std::find
algorithm:
std::vector<std::string> strs{"hello","wooorld","hi"};
std::string toFind = "abcd";
if (std::find(strs.begin(), strs.end(), toFind) != strs.end())
{
std::cout <<" abcd exist in vector of strings";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With