C语言中 printf语法printf("%d %d %c\n",a,b,c);和printf("%d %d %c\n",&a,&b,&c);什么区别?一定采纳

如题所述

首先看下printf函数的声明
int printf ( const char * format, ... );
Print formatted data to stdout
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

第一个参数format 是表示输出格式的 其中 %d 表示整形数输出 %c 表示 char类型的输出
后面的参数是和前面的带有%的格式一一对应的。
printf("%d %d %c\n",a,b,c);表示 a b以整形输出c以字符格式输出

 &这个符号在定义变量的时候是表示引用,在传递参数和赋值的时候表示取这个变量的地址。
 printf("%d %d %c\n",&a,&b,&c);表示 a b变量的地址以整形输出 c变量的地址以字符格式输出
 这种输出肯定是不对的。地址一般是%p格式输出

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-08-17
前面是输出a b c的值 ,如果定义a b c都为int型,这样输出的就是a b c的值,而后者是输出a b c的地址 一般是不会用后者的 后者的使用一般在scanf函数中,比如要输入a 整形的数值 scanf("%d",&a);这个时候一定是&a 表示a的地址。望采纳。
相似回答