刚学的,不太懂!

刚学---新手 2013-09-26 11:29:32
意思说下,求解
#include<stdio.h>
int main()
{
int a=1;
char b='1';
char c='A';
char d='a';
printf("c=%d\nb=%d\n",a,b);
printf("c=%c,c=%d\n",c,c);
printf("d=%c,d=%d\n",d,d);

return 0;

}
主要是红字部分
...全文
179 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
max_min_ 2013-09-26
  • 打赏
  • 举报
回复
多说无益阿! 看看C语言程序设计吧! 类型

printf();
//格式化输出函数!
赵4老师 2013-09-26
  • 打赏
  • 举报
回复
printf Type Field Characters The type character is the only required format field ; it appears after any optional format fields. The type character determines whether the associated argument is interpreted as a character, string, or number. The types C and S, and the behavior of c and s with printf functions, are Microsoft extensions and are not ANSI-compatible. Table R.3 printf Type Field Characters Character Type Output Format c int or wint_t When used with printf functions, specifies a single-byte character; when used with wprintf functions, specifies a wide character. C int or wint_t When used with printf functions, specifies a wide character; when used with wprintf functions, specifies a single-byte character. d int Signed decimal integer. i int Signed decimal integer. o int Unsigned octal integer. u int Unsigned decimal integer. x int Unsigned hexadecimal integer, using “abcdef.” X int Unsigned hexadecimal integer, using “ABCDEF.” e double Signed value having the form [ – ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or –. E double Identical to the e format except that E rather than e introduces the exponent. f double Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision. g double Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it. G double Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate). n Pointer to integer Number of characters successfully written so far to the stream or buffer; this value is stored in the integer whose address is given as the argument. p Pointer to void Prints the address pointed to by the argument in the form xxxx:yyyy where xxxx is the segment and yyyy is the offset, and the digits x and y are uppercase hexadecimal digits. s String When used with printf functions, specifies a single-byte–character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached. S String When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte–character string. Characters are printed up to the first null character or until the precision value is reached.
qzf362269994 2013-09-26
  • 打赏
  • 举报
回复

printf("%d",n);//用int类型的输出
printf("%i",n);//用int类型的输出
printf("%f",n);//float类型的输出
printf("%lf",n);//double类型的输出
printf("%.3f",n);//小数点后保留三位
printf("%.4lf",n);//double类型的小数点后保留4位数
printf("%s",a);//字符串的输出
puts(a);字符输出;
图灵狗 2013-09-26
  • 打赏
  • 举报
回复

// c=a的10进制值
// 换行
// b=b的10进制值
// 换行
 printf("c=%d\nb=%d\n",a,b);
// c=c所表示的字符,c=c的10进制值
// 换行
 printf("c=%c,c=%d\n",c,c);
// d=d所表示的字符,d=d的10进制值
// 换行
 printf("d=%c,d=%d\n",d,d); 
引用 楼主 u012244133 的回复:
意思说下,求解 #include<stdio.h> int main() { int a=1; char b='1'; char c='A'; char d='a'; printf("c=%d\nb=%d\n",a,b); printf("c=%c,c=%d\n",c,c); printf("d=%c,d=%d\n",d,d); return 0; } 主要是红字部分
modyaj 2013-09-26
  • 打赏
  • 举报
回复
%d 十进制输出 %c 字符输出 \n 换行 话说你什么不懂 那里需要解释 查一下printf函数的使用 应该很明了
刚学---新手 2013-09-26
  • 打赏
  • 举报
回复
真是谢谢啊!
max_min_ 2013-09-26
  • 打赏
  • 举报
回复
引用 10 楼 u012244133 的回复:
我学这得一步一步的来吧!刚学,是真不太懂!记不了那么多格式!
推荐看几本基础书籍吧! C语言程序设计 , c和数组(好好读读) 之后可以看看 c专家编程(最后再看)
modyaj 2013-09-26
  • 打赏
  • 举报
回复
引用 10 楼 u012244133 的回复:
我学这得一步一步的来吧!刚学,是真不太懂!记不了那么多格式!
在C 的世界里 这个东西太常用了 记不住没关系 记不住的时候就查一查 多了自然就会了
刚学---新手 2013-09-26
  • 打赏
  • 举报
回复
我学这得一步一步的来吧!刚学,是真不太懂!记不了那么多格式!
  • 打赏
  • 举报
回复
printf("c=%d\nb=%d\n",a,b); printf("c=%c,c=%d\n",c,c); printf("d=%c,d=%d\n",d,d); 楼主详细了解下printf函数吧。 %是格式控制符,%c打印一个字符,%d打印一个整型数
To_be_sky 2013-09-26
  • 打赏
  • 举报
回复
输出的是字符所对应的ASCLL值!
starytx 2013-09-26
  • 打赏
  • 举报
回复
看看C的基础书
Defonds 2013-09-26
  • 打赏
  • 举报
回复
这是最基础了吧

33,317

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧