万恶的linux -- 一个大小写引发的血案是看下面代码:C/C++ codeint main(void){wprintf(L%s\n, Lhello w
万恶的linux -- 一个大小写引发的血案 是看下面代码:
C/C++ code
int main(void){ wprintf(L"%s\n", L"hello world"); // line 1 wprintf(L"%s\n", "hello world"); // line 2 wprintf(L"%S\n", L"hello world"); // line 3 wprintf(L"%S\n", "hello world"); //line 4 printf("%s\n", L"hello world"); // line 5 printf("%s\n", "hello world"); // line 6 printf("%S\n", L"hello world"); // line 7 printf("%S\n", "hello world"); //line 8 return 0;}
在当前的ubuntu上运行输出的结果为: line1 -- h line2 -- hello world line3 -- hello world line4 -- ?s@!@!(乱码) line5 -- h line6 -- hello world line7 -- hello world line8 -- 无输出
[解决办法] s : When used with printf functions, specifies a single-byte-character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached. __________________________________
S : When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte-character string. Characters are printed up to the first null character or until the precision value is reached.