码迷,mamicode.com
首页 > 其他好文 > 详细

Chapter 4 Character Strings and Formatted Input/Output

时间:2016-07-21 14:47:00      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

Null Character:\0

# define TAXRATE 0.015       //when your program is compiled,the value 0.015 will be substituted everywhere you have used TAXRATE.this is called a compile-time substitution.

const int MONTHS =12;         //MONTHS a symbolic constant for 12

printf("*%10d*\n",pages);      //*       959*

printf("*%-10d*\n",pages);    //*959        *

printf("*%f*\n");                   //*3852.990000*

printf("*%e*\n");                  //*3.852900e+03*

printf("*%4.2f*\n");              //*3852.99*

printf("*%3.1f*\n");              //*3853.0*

printf("*%+4.2f*\n");            //*+3852.99*

printf("*%010.2f*\n");          //*0003852.99*

三种分行书写printf()的方法:printf("here is one way to print a");

                                      printf("long string");

                                      printf("here is another way to print a \

                                      long string");

                                      printf("here is the newest way to print a"

                                      "long string");  // ansi c

the * modifier with printf() and scanf():if you have the conversion specifier %*d,the argument list should include a value for * and a value for d.

printf("the number is :%*d\n",width,number);

printf("weight= %*.*f\n",width,precision,wight);

scanf("%*d %*d %d,&n);    //跳过相应的输入,将第三个输入的值赋给n

 

Chapter 4 Character Strings and Formatted Input/Output

标签:

原文地址:http://www.cnblogs.com/dreamer123/p/5691329.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!