工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1366|回复: 1

C printf问题

[复制链接]
发表于 2006-7-25 11:36 | 显示全部楼层 |阅读模式
在CSDN上看到的
下面的语句是用来打印buffer的前NumberOfBytesRead个字符

发觉连这个printf都没有完全学懂……

看不明白的语法

  1.   int NumberOfBytesRead=2;
  2.   char  buffer[]="adsf";
  3.   printf("%.*s\n",NumberOfBytesRead,buffer);
复制代码


手头借了本M$P的 ANSI and STANDARD C Programmer's Reference 好像说得挺详细

不过是E文 ,先发帖,再慢慢看
 楼主| 发表于 2006-7-25 13:28 | 显示全部楼层
* The width is not specified in the format string, it is specified by an integer value preceding the argument thas has to be formatted.
.precision meaning
.number for d, i, o, u, x, X types: precision specifies the minimum number of decimal digits to be printed. If the value to be printed is shorter than this number the result is padded with blanks. The value is never truncated even if the result is larger.(if nothing specified default is 1).
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2025-5-16 21:24

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表