printf()
函数中的lc(C)和c/ls(S)和s有什么区别?为什么ls(S)转换返回-1?
例子:
printf("%C", 'ͳʹ); // -1
printf("%c", 'ͳʹ); // PRINT
printf("%S", "ͳ ans T"); // -1
printf("%s", "ͳ and T"); // PRINT
在苹果机上..
最佳答案
来自手册页:
l
(ell) [...] or a following
c
conversion corresponds to awint_t
argument, or a followings
conversion corresponds to a pointer towchar_t
argument.
所以变化是预期的类型:
%c
-int
内部转换为unsigned char
%lc
-wint_t
%s
- 指向以零结尾的char
数组的指针
%ls
- 指向wchar_t
的零终止数组的指针
printf()
的负返回值,例如 -1
表示发生了错误。很难进一步确定,因为您没有显示任何代码。
关于c - printf中lc和c/ls和s的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37587777/