为什么C的格式化字符串有%c和%S两者兼而有之? [英] Why does C's printf format string have both %c and %s?
本文介绍了为什么C的格式化字符串有%c和%S两者兼而有之?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么C的格式化字符串兼得%C
和%S
?
Why does C's printf format string have both %c
and %s
?
我知道%C
重新presents单个字符和%S
重新presents字符的空终止字符串,但不会串再独自presentation够吗?
I know that %c
represents a single character and %s
represents a null-terminated string of characters, but wouldn't the string representation alone be enough?
推荐答案
大概区分之间的空结束的字符串和字符。如果他们只是有%S
,然后每一个字符,也必须以空值终止。
Probably to distinguish between null terminated string and a character. If they just had %s
, then every single character must also be null terminated.
char c = 'a';
在上述情况下, C
必须以空值终止。这是我的假设,虽然:)
In the above case, c
must be null terminated. This is my assumption though :)
这篇关于为什么C的格式化字符串有%c和%S两者兼而有之?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文