Chinaunix首页 | 论坛 | 博客
  • 博客访问: 293154
  • 博文数量: 77
  • 博客积分: 1422
  • 博客等级: 上尉
  • 技术积分: 932
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-21 12:39
文章分类
文章存档

2011年(1)

2009年(3)

2008年(73)

我的朋友

分类:

2008-07-10 11:02:35

1.P153
Between the % and the conversion character there may be, in order:
.A minus sign, which spefifies left adjustment of the ocnverted argument.
.A number that specifies the minimum field width.The converted argument will be printed in a field ate least this wide. If necessary it will be paded on the left(or rignt, if left adjustment is called for) to make up the field width.
.A period, which separates the fileld width from the precision.
.A number, the precision, that specifies the maximum number of characters to be printed from a string, or the number of digits after the decimal point of a floating point value, or the minimum number of digitals for an integer.
.An h if the integer is to be printed as a short, or l if as a long.
---------------------------------------------------------
2.P154
A width or precision may be specified as *, in which case the value is computed by converting the next argument(which must be an int). For example, to print ate most max characters from a string s,
printf("%.*s", max, s);
----------------------------------------------------------
3.P157
scanf stops when it exhausts its format string, or when some input fails to match the control specification. It returns as its value the number of successfully mached and assigned input items.
This can be used to decide how many items were found.
On end of file, EOF is returned. note that this is defferent from 0, which means that the next input character does not match the first specification in the format string.
------------------------------------------------------
4.P157
The next call to scanf resumes searching immediately after the last character already converted.
参见下面这段代码:
#include

int main(void)
{
    int a;
    int b;

    scanf("%d", &a);

    scanf("%d", &b);

    printf("a=%d  b=%d\n", a, b);

    return 0;
}

运行该程序时候,如果输入 1 2 enter
程序打印 a=1 b=2
------------------------------------------------------------
5.

阅读(1405) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~