"'之间'和&QUOT差异; C [英] Differences between '' and "" C

查看:147
本文介绍了"'之间'和&QUOT差异; C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Recentely我已经看到,如果我使用的printf 与'富',我得到一个警告。

 的printf(NUMERO');


  

警告:字符常量太长,其类型[默认启用]
  警告:传递printf式的参数1,使指针从整
  没有一个演员。 /usr/include/stdio.h:362:12:注:应为常数
  字符* 限制,但参数的类型为INT的extern INT的printf
  (为const char * __限制__format,...);警告:格式不是字符串
  文字,没有格式参数[-Wformat安全]


<;当我使用我没有得到任何警告的printf(NUMERO),

和/ p>

那么,有什么的区别


解决方案

在的ç用于字符常量和字符串,不像< A HREF =/问题/标记/蟒蛇类=标签后称号=显示标记的问题'巨蟒'其中两个可以互换使用的rel =标签>蟒蛇。

Recentely I have seen that if I use printf with 'foo' I get a warning.

printf('numero');

warning: character constant too long for its type [enabled by default] warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast. /usr/include/stdio.h:362:12: note: expected ‘const char * restrict’ but argument is of type ‘int’ extern int printf (const char *__restrict __format, ...); warning: format not a string literal and no format arguments [-Wformat-security]

And when I use "" I don't get any warnings printf("numero");

So, what's the difference between '' and ""?

解决方案

In , '' is used for character constants and "" for string, unlike where both can be used interchangeably.

这篇关于&QUOT;'之间'和&QUOT差异; C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆