theitroad>C Programming Basic>Standard Library Functions>stdio.h>C programming stdio.h function - int vsprintf(char *str, const char *format, va_list arg)
- Standard Library Functions
- ctype.h
- C programming ctype.h function - int isalnum(int c)
- C programming ctype.h function - int isalpha(int c)
- C programming ctype.h function - int iscntrl(int c)
- C programming ctype.h function - int isdigit(int c)
- C programming ctype.h function - int isgraph(int c)
- C programming ctype.h function - int islower(int c)
- C programming ctype.h function - int isprint(int c)
- C programming ctype.h function - int ispunct(int c)
- C programming ctype.h function - int isspace(int c)
- C programming ctype.h function - int isupper(int c)
- C programming ctype.h function - int isxdigit(int c)
- C programming ctype.h function - int tolower(int c)
- C programming ctype.h function - int toupper(int c)
- locale.h
- C programming locale.h function - char *setlocale(int category, const char *locale)
- C programming locale.h function - struct lconv *localeconv(void)
- math.h
- C programming math.h function - double exp(double x)
- C programming math.h function - double frexp(double x, int *exponent)
- C programming math.h function - double ldexp(double x, int exponent)
- C programming math.h function - double log(double x)
- C programming math.h function - double log10(double x)
- C programming math.h function - double modf(double x, double *integer)
- C programming math.h function - double asin(double x)
- C programming math.h function - double atan(double x)
- C programming math.h function - double atan2(double y, double x)
- C programming math.h function - double cos(double x)
- C programming math.h function - double cosh(double x)
- C programming math.h function - double sin(double x)
- C programming math.h function - double sinh(double x)
- C programming math.h function - double tanh(double x)
- C programming math.h function - double acos(double x)
- setjmp.h
- C programming setjmp.h function - void longjmp(jmp_buf environment, int value)
- signal.h
- C programming signal.h function - void (*signal(int sig, void (*func)(int)))(int)
- C programming signal.h function - int raise(int sig)
- stdarg.h
- C programming stdarg.h Macro - void va_start(va_list ap, last_arg)
- C programming stdarg.h Macro - type va_arg(va_list ap, type)
- C programming stdarg.h Macro - void va_end(va_list ap)
- stdio.h
- C programming stdio.h function - int fclose(FILE *stream)
- C programming stdio.h function - void clearerr(FILE *stream)
- C programming stdio.h function - int feof(FILE *stream)
- C programming stdio.h function - int ferror(FILE *stream)
- C programming stdio.h function - int fflush(FILE *stream)
- C programming stdio.h function - int fgetpos(FILE *stream, fpos_t *pos)
- C programming stdio.h function - FILE *fopen(const char *filename, const char *mode)
- C programming stdio.h function - size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
- C programming stdio.h function - FILE *freopen(const char *filename, const char *mode, FILE *stream)
- C programming stdio.h function - int fseek(FILE *stream, long int offset, int whence)
- C programming stdio.h function - int fsetpos(FILE *stream, const fpos_t *pos)
- C programming stdio.h function - long int ftell(FILE *stream)
- C programming stdio.h function - size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
- C programming stdio.h function - int remove(const char *filename)
- C programming stdio.h function - int rename(const char *old_filename, const char *new_filename)
- C programming stdio.h function - void rewind(FILE *stream)
- C programming stdio.h function - void setbuf(FILE *stream, char *buffer)
- C programming stdio.h function - int setvbuf(FILE *stream, char *buffer, int mode, size_t size)
- C programming stdio.h function - FILE *tmpfile(void)
- C programming stdio.h function - char *tmpnam(char *str)
- C programming stdio.h function - int fprintf(FILE *stream, const char *format, ...)
- C programming stdio.h function - int printf(const char *format, ...)
- C programming stdio.h function - int sprintf(char *str, const char *format, ...)
- C programming stdio.h function - int vfprintf(FILE *stream, const char *format, va_list arg)
- C programming stdio.h function - int vprintf(const char *format, va_list arg)
- C programming stdio.h function - int vsprintf(char *str, const char *format, va_list arg)
- C programming stdio.h function - int fscanf(FILE *stream, const char *format, ...)
- C programming stdio.h function - int scanf(const char *format, ...)
- C programming stdio.h function - int sscanf(const char *str, const char *format, ...)
- C programming stdio.h function - int fgetc(FILE *stream)
- C programming stdio.h function - char *fgets(char *str, int n, FILE *stream)
- C programming stdio.h function - int fputc(int char, FILE *stream)
- C programming stdio.h function - int fputs(const char *str, FILE *stream)
- C programming stdio.h function - int getc(FILE *stream)
- C programming stdio.h function - int getchar(void)
- C programming stdio.h function - char *gets(char *str)
- C programming stdio.h function - int putc(int char, FILE *stream)
- C programming stdio.h function - int putchar(int char)
- C programming stdio.h function - int puts(const char *str)
- C programming stdio.h function - int ungetc(int char, FILE *stream)
- C programming stdio.h function - void perror(const char *str)
- stdlib.h
- C programming stdlib.h function - double atof(const char *str)
- C programming stdlib.h function - int atoi(const char *str)
- C programming stdlib.h function - long int atol(const char *str)
- C programming stdlib.h function - double strtod(const char *str, char **endptr)
- C programming stdlib.h function - long int strtol(const char *str, char **endptr, int base)
- C programming stdlib.h function - unsigned long int strtoul(const char *str, char **endptr, int base)
- C programming stdlib.h function - void *calloc(size_t nitems, size_t size)
- C programming stdlib.h function - void free(void *ptr)
- C programming stdlib.h function - void *malloc(size_t size)
- C programming stdlib.h function - void *realloc(void *ptr, size_t size)
- C programming stdlib.h function - void abort(void)
- C programming stdlib.h function - int atexit(void (*func)(void))
- C programming stdlib.h function - void exit(int status)
- C programming stdlib.h function - char *getenv(const char *name)
- C programming stdlib.h function - int system(const char *string)
- C programming stdlib.h function - void *bsearch(const void *key, const void *base, size_t nitems, size_t size, int (*compar)(con
- C programming stdlib.h function - void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void , const void))
- C programming stdlib.h function - int abs(int x)
- C programming stdlib.h function - div_t div(int numer, int denom)
- C programming stdlib.h function - long int labs(long int x)
- C programming stdlib.h function - ldiv_t ldiv(long int numer, long int denom)
- C programming stdlib.h function - int rand(void)
- C programming stdlib.h function - void srand(unsigned int seed)
- C programming stdlib.h function - int mblen(const char *str, size_t n)
- C programming stdlib.h function - size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)
- C programming stdlib.h function - int mbtowc(whcar_t *pwc, const char *str, size_t n)
- C programming stdlib.h function - size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)
- C programming stdlib.h function - int wctomb(char *str, wchar_t wchar)
- string.h
- C programming string.h function - void *memchr(const void *str, int c, size_t n)
- C programming string.h function - int memcmp(const void *str1, const void *str2, size_t n)
- C programming string.h function - void *memcpy(void *dest, const void *src, size_t n)
- C programming string.h function - void *memmove(void *dest, const void *src, size_t n)
- C programming string.h function - void *memset(void *str, int c, size_t n)
- C programming string.h function - char *strcat(char *dest, const char *src)
- C programming string.h function - char *strncat(char *dest, const char *src, size_t n)
- C programming string.h function - char *strchr(const char *str, int c)
- C programming string.h function - int strcmp(const char *str1, const char *str2)
- C programming string.h function - int strncmp(const char *str1, const char *str2, size_t n)
- C programming string.h function - int strcoll(const char *str1, const char *str2)
- C programming string.h function - char *strcpy(char *dest, const char *src)
- C programming string.h function - char *strncpy(char *dest, const char *src, size_t n)
- C programming string.h function - size_t strcspn(const char *str1, const char *str2)
- C programming string.h function - char *strerror(int errnum)
- C programming string.h function - size_t strlen(const char *str)
- C programming string.h function - char *strpbrk(const char *str1, const char *str2)
- C programming string.h function - char *strrchr(const char *str, int c)
- C programming string.h function - size_t strspn(const char *str1, const char *str2)
- C programming string.h function - char *strstr(const char *haystack, const char *needle)
- C programming string.h function - char *strtok(char *str, const char *delim)
- C programming string.h function - size_t strxfrm(char *dest, const char *src, size_t n)
- time.h
- C programming time.h function - char *asctime(const struct tm *timeptr)
- C programming time.h function - clock_t clock(void)
- C programming time.h function - char *ctime(const time_t *timer)
- C programming time.h function - double difftime(time_t time1, time_t time2)
- C programming time.h function - struct tm *gmtime(const time_t *timer)
- C programming time.h function - struct tm *localtime(const time_t *timer)
- C programming time.h function - time_t mktime(struct tm *timeptr)
- C programming time.h function - size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr)
- C programming time.h function - time_t time(time_t *timer)
C programming stdio.h function - int vsprintf(char *str, const char *format, va_list arg)
The vsprintf
function in the stdio.h
library of C programming language is used to write formatted data to a character string. It is similar to the sprintf
function, but takes a va_list
argument instead of a variable number of arguments.
The syntax of the vsprintf
function is as follows:
int vsprintf(char *str, const char *format, va_list arg);Scruoe:www.theitroad.com
Here, str
is a pointer to the character string where the output will be stored, format
is a string that specifies the format of the output, and arg
is a va_list
variable that contains the arguments to be formatted.
The function returns the number of characters written to the string, not including the null terminator.
Here's an example that uses vsprintf
to format a string:
#include <stdio.h> #include <stdarg.h> int main() { char buffer[100]; int n = 42; const char* str = "Hello, world!"; vsprintf(buffer, "n = %d, str = %s", n, str); printf("%s\n", buffer); return 0; }
This program will output:
n = 42, str = Hello, world!