Chapter 4 Character Strings and Formatted Input/Output

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

 

posted @ 2016-07-21 12:39  dreamer123  阅读(198)  评论(0编辑  收藏  举报