Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
For NULL-embedded strings, CStringT::Find() produces what you may not expect
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86 #include <cstdio> #include <atlstr.h> #define DIMENSION(array) (sizeof(array) / sizeof(array[0])) int main() { unsigned char bytes[10] = { '\x53', '\x53', '\x53', '\x53', '\x00', '\x11', '\x53', '\x53', '\x53', '\x53' }; CStringA string(reinterpret_cast<char*>(bytes), DIMENSION(bytes)); for (int i = 0; i < string.GetLength(); ++i) { printf("0x%02x ", string[i]); } putchar('\n'); printf("%d\n", string.Find('\x11')); // -1 (!) }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
ADL of operator expression & unqualified function call
du
Test
template test
hangman
error_check
#22.2
#26.fix
seh exception in constructor memory leak
Unicode_write2file
Please log in to post a comment.