<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語言宏
<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語言

vsprintf() - C語言庫函數

C庫函數 int vsprintf(char *str, const char *format, va_list arg) 發送格式化輸出到一個字符串傳遞給它的參數列表。 


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

int vsprintf(char *str, const char *format, va_list arg)


  • str -- 這是生成的字符串是存儲char元素的數組。

  • format -- 這是C字符串,其中包含的文字要寫入str.It可以包含嵌入格式標籤,在隨後的附加參數指定的值所取代和格式化的要求。格式標籤原型:%[flags][width][.precision][length]specifier, 詳細說明如下:





d or i

Signed decimal integer


Scientific notation (mantissa/exponent) using e character


Scientific notation (mantissa/exponent) using E character


Decimal floating yiibai


Use the shorter of %e or %f.


Use the shorter of %E or %f


Signed octal


String of characters


Unsigned decimal integer


Unsigned hexadecimal integer


Unsigned hexadecimal integer (capital letters)


Yiibaier address


Nothing printed.






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..


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.


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




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.




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.




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


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.


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

  • arg -- 可變參數列表中的對象。這應該是初始化va_start宏在定義。




下面的例子演示瞭如何使用 vsprintf() 函數。

#include <stdio.h> #include <stdarg.h> char buffer[80]; int vspfunc(char *format, ...) { va_list aptr; int ret; va_start(aptr, format); ret = vsprintf(buffer, format, aptr); va_end(aptr); return(ret); } int main() { int i = 5; float f = 27.0; char str[50] = "tutoriasyiibai.com"; vspfunc("%d %f %s", i, f, str); printf("%s
", buffer); return(0); }


5 27.000000 tutoriasyiibai.com