警告:多字符字符常量 [-Wmultichar]| [英] warning: multi-character character constant [-Wmultichar]|
问题描述
/* Beginning 2.0 */
#include<stdio.h>
main()
{
printf(" %d signifies the %c of %f",9,'rise',17.0);
return 0;
}
大家好
当我编译这个时,编译器给出以下警告:
When I compile this, the compiler giving the following warning:
warning: multi-character character constant [-Wmultichar]|
并且输出只打印 e
而不是 rise
.
And the output only prints e
instead of rise
.
C语言中不允许有多个字符吗?
Are multiple characters not allowed in C?
如何打印整个单词(rise
)?
How can I print the whole word (rise
)?
请帮帮我.
推荐答案
试试:printf(" %d 表示 %f 的 %s",9,"rise",17.0);
.
C 区分字符(一个字符)和字符字符串(可以包含任意数量的字符).您使用单引号 (''
) 表示字符文字,但使用双引号表示字符 string 文字.
C distinguishes between a character (which is one character) and a character string (which can contain an arbitrary number of characters). You use single quotes (''
) to signify a character literal, but double quotes to signify a character string literal.
同样,您指定 %c
来转换单个字符,而指定 %s
来转换字符串.
Likewise, you specify %c
to convert a single character, but %s
to convert a string.
这篇关于警告:多字符字符常量 [-Wmultichar]|的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!