c语言see函数,vprintf() - C语言库函数

C库函数  int vprintf(const char *format, va_list arg)  发送格式化输出到stdout使用一个参数列表传递给它。

声明

以下是 vprintf() 函数的声明。

intvprintf(constchar*format,va_list arg)

参数

format -- 这是包含文本的字符串被写入到缓冲。它可以包含嵌入的格式在随后的附加参数指定的值所取代的标签和格式化的要求。格式标签原型将是: %[flags][width][.precision][length]specifier, 详细说明如下:

修辞符

输出

c

Character.

d or i

Signed decimal integer

e

Scientific notation (mantissa/exponent) using e character

E

Scientific notation (mantissa/exponent) using E character

f

Decimal floating yiibai

g

Use the shorter of %e or %f.

G

Use the shorter of %E or %f

o

Signed octal

s

String of characters

u

Unsigned decimal integer

x

Unsigned hexadecimal integer

X

Unsigned hexadecimal integer (capital letters)

p

Yiibaier address

n

Nothing printed.

%

Character.

flags

描述

-

Left-justify within the given field width; Right justification is the default (see width sub-specifier).

+

Forces to preceed the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign..

(space)

If no sign is going to be written, a blank space is inserted before the value.

#

Used with o, x or X specifiers the value is preceeded with 0, 0x or 0X respectively for values different than zero. Used with e, E and f, it forces the written output to contain a decimal yiibai even if no digits would follow. By default, if no digits follow, no decimal yiibai is written. Used with g or G the result is the same as with e or E but trailing zeros are not removed.

0

Left-pads the number with zeroes (0) instead of spaces, where padding is specified (see width sub-specifier).

width

描述

(number)

Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger.

*

The width is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.

.precision

描述

.number

For integer specifiers (d, i, o, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0. For e, E and f specifiers: this is the number of digits to be printed after de decimal yiibai. For g and G specifiers: This is the maximum number of significant digits to be printed. For s: this is the maximum number of characters to be printed. By default all characters are printed until the ending null character is encountered. For c type: it has no effect. When no precision is specified, the default is 1. If the period is specified without an explicit value for precision, 0 is assumed.

.*

The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.

length

描述

h

The argument is interpreted as a short int or unsigned short int (only applies to integer specifiers: i, d, o, u, x and X).

l

The argument is interpreted as a long int or unsigned long int for integer specifiers (i, d, o, u, x and X), and as a wide character or wide character string for specifiers c and s.

L

The argument is interpreted as a long double (only applies to floating yiibai specifiers: e, E, f, g and G).

arg -- 可变参数列表中的对象。这应该是初始化va_start宏在定义。

返回值

如果成功,则返回写入的字符的总数,否则返回一个负数。

例子

下面的例子演示了如何使用vprintf() 函数。

#include#includevoidWriteFrmtd(char*format,...){va_list args;va_start(args,format);vprintf(format,args);va_end(args);}intmain(){WriteFrmtd("%d variable argument

",1);WriteFrmtd("%d variable %s

",2,"arguments");return(0);}

让我们编译和运行上面的程序,这将产生以下结果:

1 variable argument

2 variable arguments

¥ 我要打赏

纠错/补充

收藏

加QQ群啦,易百教程官方技术学习群

注意:建议每个人选自己的技术方向加群,同一个QQ最多限加 3 个群。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/419996.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

js获取checkbox值的方法

js获取checkbox值的方法。分享给大家供大家参考。具体实现方法如下&#xff1a;<html> <head> <meta http-equiv"Content-Type" content"text/html; charsetutf-8"> <title>js</title> </head> <script language&q…

c语言占用cpu的程序,Windows下用C语言获取进程cpu使用率,内存使用,IO情况

转自&#xff1a; http://zhangyafeikimi.iteye.com/blog/378658process_stat.h/** file * brief 进程统计信息函数的声明 * author 张亚霏 * date 2009/05/03 * version 0.1 * */ #ifndef PROCESS_STAT_H #define PROCESS_STAT_H #ifdef __cplusplus extern "C" { #…

oracle 本地使用命令导入数据到远程主机

第一步:装载oracle客户端 第二部:配置tnsnames.ora.  db_172.21.1.7 (DESCRIPTION (ADDRESS (PROTOCOL TCP)(HOST 172.21.1.7)(PORT 1526))(CONNECT_DATA (SERVER DEDICATED)(SERVICE_NAME db))) 第三部:打开命令行,执行如下命令: imp netelnusr/netelnusrdb_172.21.1.7…

c语言计算据标准时间多少天,C语言系列--时间处理

首先明确几个概念UTC 协调世界时&#xff0c;又称世界标准时间或世界协调时间。GMT 格林尼治平均时间或格林尼治标准時間&#xff0c;由于地球每天的自转是有些不规则的&#xff0c;而且正在缓慢减速&#xff0c;因此格林威治时间已经不再被作为标准时间使用日历时间&#xff0…

Perl学习笔记(六)--文件(一)

一、文件描述符&#xff1a; 访问文件时用来代表文件的数字。 它是系统资源&#xff0c;系统限制打开的文件描述符数量。 Perl中只在某些系统调用时才使用它 文件句柄&#xff1a; 功能同文件描述符&#xff0c;但是与文件描述符不是一个东西。 Perl使用文件句柄代表文件。 文件…

android mkdirs 不起作用,Android mkdirs()创建一个零字节文件而不是文件夹

在我的Android应用程序中,我试图在SD卡上创建以下文件夹&#xff1a;/mnt/sdcard/OSGiComponents/admin/felix-cache/这是代码&#xff1a;File cacheDir new File( Environment.getExternalStorageDirectory().getAbsolutePath() "/OSGiComponents/admin/felix-cache/&qu…

向ComboBox列表框中添加Enum的全部数据

相当于利用反射的 GetValues与GetNames foreach (HETieXinType theType in Enum.GetValues(typeof(HETieXinType))) foreach (string mode in Enum.GetNames(typeof(BooleanInteractionMode))) { ledResponseModesComboBox.Items.Add(mode); switchResponseModesComboBox.Items…

android sqlite 备份数据库文件,android – 将SQLite数据库备份和还原到sdcard

这是我的代码&#xff1a;// Local databaseInputStream input new FileInputStream(from);// create directory for backupFile dir new File(DB_BACKUP_PATH);dir.mkdir();// Path to the external backupOutputStream output new FileOutputStream(to);// transfer bytes…

Spring中配置数据源的4种形式 ---转

不管采用何种持久化技术&#xff0c;都需要定义数据源。Spring中提供了4种不同形式的数据源配置方式&#xff1a; spring自带的数据源(DriverManagerDataSource)&#xff0c;DBCP数据源&#xff0c;C3P0数据源,JNDI数据源。 1.spring自带的数据源 DriverManagerDataSource XML…

android中拖动文字实现功能,Android:图片中叠加文字,支持拖动改变位置

之所以做了这么一个Demo&#xff0c;是因为最近项目中有一个奇葩的需求&#xff1a;用户拍摄照片后&#xff0c;分享到微信的同时添加备注&#xff0c;想获取用户在微信的弹出框输入的内容&#xff0c;保存在自己的服务器上。而事实上&#xff0c;这个内容程序是无法获取的&…

Mac 下nginx 环境的配置

这个是在度娘那里学来的。 因为是使用brew所以先安装&#xff1a; 安装命令如下&#xff1a;curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1当brew安装成功后&#xff0c;就可以随意安装自己想要的软件了&#xff0c;例如w…

android抽屉屏幕右滑,android - Android - 使滑动抽屉从左向右滑动 - 堆栈内存溢出...

我使用下面的XML布局在我的应用程序中实现了“Sliding Drawer”:(我从androidpeople.com得到了这个例子)android:layout_width"fill_parent" android:layout_height"fill_parent"xmlns:android"http://schemas.android.com/apk/res/android"andr…

bzoj 3196/tyvj p1730 二逼平衡树

原题链接&#xff1a;http://www.tyvj.cn/p/1730 树套树。。。 如下&#xff1a; 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<algorithm> 5 #define lc root<<1 6 #define rc root<<1|1 7 #define INF…

观察者模式与Boost.Signals

1&#xff09; 观察者模式定义 略&#xff0c;各种设计模式的书上都有定义。 2&#xff09; 观察者模式一般实现 观察者模式一般实现&#xff0c;都是“被观察者”保存一个“观察者”的列表&#xff0c;循环这个列表来通知“观察者”。代码&#xff0c;其中使用了boost的智能…

Android获取最新发送短信的基本信息,没有之一

注册&#xff1a; getContentResolver().registerContentObserver( Uri.parse("content://sms"), true, new SmsObserver(this, new Handler())); 监听&#xff1a; //用于检测发出的短信 public class SmsObserver extends Conten…

联想android刷机教程,超详细的联想刷机教程~带你嘻刷刷

一、刷机是什么说到“刷机”&#xff0c;很多人可能会和“升级”混淆起来&#xff0c;其实升级和刷机并不是同一概念。通俗地讲&#xff0c;升级就是对手机内的软件或系统进行升级&#xff0c;比如很多厂商手机都支持的OTA空中在线升级。而刷机&#xff0c;则相当于就是重装系统…

我的github地址

我的github仓库地址 https://github.com/xutiantian/Test转载于:https://www.cnblogs.com/xuxiaomeng/p/4455850.html

多看 android6,多看阅读本地版

为您推荐&#xff1a;多看阅读《多看阅读本地版》是一款由多看科技倾情研发打造的海量优质完本小说免费在线阅读app软件&#xff0c;这款软件的功能非常的全面&#xff0c;操作性简单&#xff0c;上手起来非常的容易&#xff0c;在这款软件里&#xff0c;各位用户们将能够于此体…

UIProgressView-初识IOS

好几天没更新了&#xff0c;学的时候太紧&#xff0c;没时间复习了都。今天刚好有时间&#xff0c;多更几个。 今天复习的是UIProgressView,我们常见使用在修改某些属性的时候经常用到&#xff0c;比如透明度&#xff0c;今天我们介绍一个简单的使用例子 定义什么的&#xff0c…