| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- print formatted output of a variable argument list
#include <stdio.h>#include <stdarg.h>intvprintf(const char *format,va_listap);
intvfprintf(FILE *stream,const char *format,va_listap);
intvsprintf(char *s,const char *format,va_listap);
intvsnprintf(char *s,size_tn,const char *format,va_listap);
intvasprintf(char **ret,const char *format,va_listap);
Thevprintf(),vfprintf(),vsprintf(),vsnprintf(), andvasprintf() functions are the same asprintf(),fprintf(),sprintf(),snprintf(), andasprintf(), respectively, except that instead of beingcalled with a variable number of arguments, they are called with anargument list as defined in the<stdarg.h> header. Seeprintf(3C).
The<stdarg.h> header defines the typeva_list and a set of macrosfor advancing through a list of arguments whose number and types mayvary. The argumentap to thevprint family of functions is of typeva_list. This argument is used with the <stdarg.h> header file macrosva_start(),va_arg(), andva_end() (seestdarg(3EXT)). TheEXAMPLES section below demonstrates the useofva_start() andva_end() withvprintf().
The macrova_alist() is used as the parameter list in a functiondefinition, as in the function callederror() in the example below. Themacrova_start(ap, name), whereap is of typeva_list andname is the rightmostparameter (just before . . .), must be called before any attempt to traverseand access unnamed arguments is made. Theva_end(ap) macro must be invokedwhen all desired arguments have been accessed. The argument list inapcan be traversed again ifva_start() is called again afterva_end(). Inthe example below, theerror() arguments (arg1,arg2, …) are passed tovfprintf() in the argumentap.
Refer toprintf(3C).
Thevprintf() andvfprintf() functions will fail if either thestream isunbuffered or thestream's buffer needed to be flushed and:
The file is a regular file and an attempt was made to write at or beyond the offset maximum.
Example 1 Usingvprintf() to write an error routine.
The following demonstrates howvfprintf() could be used to write an errorroutine:
#include <stdio.h>#include <stdarg.h>. . ./* * error should be called like * error(function_name, format, arg1, …); */void error(char *function_name, char *format, …){ va_list ap; va_start(ap, format); /* print out name of function causing error */ (void) fprintf(stderr, "ERR in %s: ", function_name); /* print out remainder of message */ (void) vfprintf(stderr, format, ap); va_end(ap); (void) abort();}Seeattributes(5) for descriptions of the following attributes:
|
All of these functions can be used safely in multithreaded applications, aslong assetlocale(3C) is not being called to change the locale.
Seestandards(5) for the standards conformance ofvprintf(),vfprintf(),vsprintf(), andvsnprintf().Thevasprintf() function is modeled on the one that appears in theFreeBSD, NetBSD, and GNU C libraries.
printf(3C),attributes(5),stdarg(3EXT),attributes(5),standards(5)
Thevsnprintf() return value whenn = 0 was changed in theSolaris 10 release. The change was based on the SUSv3 specification. Theprevious behavior was based on the initial SUSv2 specification, wherevsnprintf() whenn = 0 returns an unspecified value less than 1.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |