1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #include <string>
#include <stdio.h>
using std::wstring;
int main(int argc, char** argv)
{
std::wstring wsChunk = L", either OFF or +APC or +DEM ";
std::wstring::size_type pos = wsChunk.find( L"+APC or ");
std::wstring::size_type mpos = wsChunk.find( L"or +APC or ");
printf("%d, %d\n", pos, mpos); // 16, 13
wsChunk = L"+APC or ";
pos = wsChunk.find( L"+APC or ");
mpos = wsChunk.find( L"or +APC or ");
printf("%d, %d\n", pos, mpos); // 0, -1
if (mpos == std::wstring::npos) {
printf("No found: \"or +APC or \"\n");
}
wsChunk = L", either OFF or +APC or +DEM ";
pos = wsChunk.find( L"+APC or ");
mpos = wsChunk.find( L"OFF or +APC or ");
printf("%d, %d\n", pos, mpos); // 16, 9
return 0;
} |
Partager