#include <iostream> #include <cstring> int main() { auto l = std::strlen("123\0456\0"); std::cout << l << std::endl; }
为什么这段代码的输出是5?
我预计 3。
这是要测试的在线版本:https : //ideone.com/UQRKlV
c++ string strlen
c++ ×1
string ×1
strlen ×1