check if a pointer has some string c++ -
I'm not good with c ++ and I can not find it anywhere, please apologize to me if this is a The bad question is, I have an indicator and I want to know that some name stores in this indicator starts with some special string. Something like a dragon (maybe this is a bad example):
If 'pointer_name' has 'pre': I have it:
double t = 0; (Size_t i = 0; i
Pre-code in the string_name of python> Is: string_name.find ("pre")! = Std :: string :: npos // If string is std :: strstr (pointer_name, "pre") // if Python string_name.startswith ('pre') * < P> ("starts with some specific string"): string_name.size ()> gt; = 3 & amp; Amp; Std :: equal (string_name.begin (), string_name.begin () + 3, "pre"); // If string is // less / less efficient using string_name.find ("pre"), but less standard :: strncmp (pointer_name, "pre", 3) == 0 // if char * < / Code> In those two cases, in practice, you can avoid using a literal 3 by measuring the string.
Comments
Post a Comment