两者都works[5]
导致doesntWork[5]
未定义的行为。缓冲区仅在 之前有效[4]
,并且[5]
在此范围之外。
const wchar_t *works = L"Test";
works[0] -> L'T'
works[1] -> L'e'
works[2] -> L's'
works[3] -> L't'
works[4] -> L'\0'
works[5] -> undefined behavior, the program is broken if it ever tries to access this