C語言標準庫
C語言標準庫
<assert.h> - C語言標準庫
C函數庫宏 assert()
<ctype.h> - C語言標準庫
isalnum() - C函數
isalpha() - C函數
iscntrl() - C函數
isdigit() - C函數
isgraph() - C函數
islower() - C函數
isprint() - C函數
ispunct() - C函數
isspace() - C函數
isupper() - C函數
isxdigit() - C函數
tolower() - C函數
toupper() - C函數
<errno.h> - C語言標準庫
errno - C語言宏
EDOM - C語言宏
ERANGE - C語言宏
<float.h> - C語言標準庫
<limits.h> - C語言標準庫
<locale.h> - C語言標準庫
setlocale() - C函數
localeconv() - C函數
<math.h> - C語言標準庫
acos() - C函數
asin() - C函數
atan() - C函數
atan2() - C函數
cos() - C函數
sin() - C函數
sinh() - C函數
tanh() - C函數
exp() - C函數
frexp() - C函數
ldexp() - C函數
log() - C函數
log10() - C函數
modf() - C函數
pow() - C函數
sqrt() - C函數
ceil() - C函數
fabs() - C函數
floor() - C函數
fmod() - C函數
<setjmp.h> - C語言標準庫
setjmp() - C函數
longjmp() - C函數
<signal.h> - C語言標準庫
signal() - C函數
raise() - C函數
<stdarg.h> - C語言標準庫
va_start() - C函數
va_arg() - C函數
va_end() - C函數
<stddef.h> - C語言標準庫
NULL - C函數
offsetof() - C函數
<stdio.h> - C語言標準庫
clearerr() - C庫函數
fclose() - C庫函數
feof() - C庫函數
ferror() - C庫函數
fflush() - C庫函數
fgetpos() - C庫函數
fopen() - C語言庫函數
fread() - C語言庫函數
freopen() - C語言庫函數
fseek() - C語言庫函數
fsetpos() - C語言庫函數
ftell() - C語言庫函數
fwrite() - C語言庫函數
remove() - C語言庫函數
rename() - C語言庫函數
rewind() - C語言庫函數
setbuf() - C語言庫函數
setvbuf() - C語言庫函數
tmpfile() - C語言庫函數
tmpnam() - C語言庫函數
fprintf() - C語言庫函數
printf() - C語言庫函數
sprintf() - C語言庫函數
vfprintf() - C語言庫函數
vprintf() - C語言庫函數
vsprintf() - C語言庫函數
fscanf() - C語言庫函數
scanf() - C語言庫函數
sscanf() - C語言庫函數
fgetc() - C語言庫函數
fgets() - C語言庫函數
fputc() - C語言庫函數
fputs() - C語言庫函數
getc() - C語言庫函數
getchar() - C語言庫函數
gets() - C語言庫函數
putc() - C語言庫函數
putchar() - C語言庫函數
puts() - C語言庫函數
ungetc() - C語言庫函數
perror() - C語言庫函數
<stdlib.h> - C語言標準庫
atof() - C語言庫函數
atoi() - C語言庫函數
atol() - C語言庫函數
strtod() - C語言庫函數
strtol() - C語言庫函數
strtoul() - C語言庫函數
calloc() - C語言庫函數
free() - C語言庫函數
malloc() - C語言庫函數
realloc() - C語言庫函數
abort() - C語言庫函數
atexit() - C語言庫函數
exit() - C語言庫函數
getenv() - C語言庫函數
system() - C語言庫函數
bsearch() - C語言庫函數
qsort() - C語言庫函數
abs() - C語言庫函數
div() - C語言庫函數
labs() - C語言庫函數
ldiv() - C語言庫函數
rand() - C語言庫函數
srand() - C語言庫函數
mblen() - C語言庫函數
mbstowcs() - C語言庫函數
mbtowc() - C語言庫函數
wcstombs() - C語言庫函數
wctomb() - C語言庫函數
<string.h> - C語言標準庫
memchr() - C語言庫函數
memcmp() - C語言庫函數
memcpy() - C語言庫函數
memmove() - C語言庫函數
memset() - C語言庫函數
strcat() - C語言庫函數
strncat() - C語言庫函數
strchr() - C語言庫函數
strcmp() - C語言庫函數
strncmp() - C語言庫函數
strcoll() - C語言庫函數
strcpy() - C語言庫函數
strcspn() - C語言庫函數
strerror() - C語言庫函數
strlen() - C語言庫函數
strpbrk() - C語言庫函數
strrchr() - C語言庫函數
strspn() - C語言庫函數
strstr() - C語言庫函數
strtok() - C語言庫函數
strxfrm() - C語言庫函數
<time.h> - C語言標準庫
asctime() - C語言庫函數
clock() - C語言庫函數
ctime() - C語言庫函數
difftime() - C語言庫函數
gmtime() - C語言庫函數
localtime() - C語言庫函數
mktime() - C語言庫函數
strftime() - C語言庫函數
time() C語言

vprintf() - C語言庫函數

C庫函數  int vprintf(const char *format, va_list arg)  發送格式化輸出到stdout使用一個參數列表傳遞給它。

聲明

以下是 vprintf() 函數的聲明。

int vprintf(const char *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 <stdio.h> #include <stdarg.h> void WriteFrmtd(char *format, ...) { va_list args; va_start(args, format); vprintf(format, args); va_end(args); } int main () { WriteFrmtd("%d variable argument
", 1); WriteFrmtd("%d variable %s
", 2, "arguments"); return(0); }

讓我們編譯和運行上面的程序,這將產生以下結果:

1 variable argument
2 variable arguments