c++ Search for char in char function? -
i have googled lot search solution, non far! need search in char variable char match.
char somechar[] = { 0xc1, 0xc2, 0xd4, 0xd3 }; if (strchr(somechar, '0xd3') == null) { // did not find it! } strstr not work, strchar not work, ant other solution?
many thanks!
note need careful using values high signed chars.
example, 0xd3 == (char)0xd3 not true, whereas 0xd3 == (unsigned char)0xd3 is.
an example std::find:
char somechar[] { 0x31, 0xc2, 0xd4, 0xd3 }; auto loc = std::find(std::begin(somechar), std::end(somechar), (char)0xd3); std::cout << "found @ " << std::distance(std::begin(somechar),loc) << std::endl;
Comments
Post a Comment