What's the difference between printf(“%s”), printf(“%ls”), wprintf(“%s”), and wprintf(“%ls”)?
问题 Consider this sample program: #include <cstdio> #include <cwchar> #include <string> int main() { std::string narrowstr = "narrow"; std::wstring widestr = L"wide"; printf("1 %s \n", narrowstr.c_str()); printf("2 %ls \n", widestr.c_str()); wprintf(L"3 %s \n", narrowstr.c_str()); wprintf(L"4 %ls \n", widestr.c_str()); return 0; } The output of this is: 1 narrow 2 wide I'm wondering: why 3 & 4 didn't print what the differences are between 1&3, and 2&4. does it make any difference if narrowstr is