相关代码:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
cout << sizeof("\n\r\t") << endl; // prints 4
cout << strlen("\n\r\t") << endl; // print 3
return 0;
}
我很困惑,因为我一直以为sizeof
char的标准大小应该是1个字节,但是在上面的代码中,输出的结果是4。
这是否有解释或者对于转义字符有例外情况?请帮助我理解。