sprintf : sprintf « stdio.h « C Tutorial






ItemValue
Header filestdio.h
Declarationint sprintf(char *buf, const char *format, ...);
FunctionIt is identical to printf() except that the output is a char array.
Returnreturns the number of characters actually placed into the array.


sprintf() provides no bounds checking. See snprintf for an alternative.

#include <stdio.h>

int main(void){
  char str[80];

  sprintf(str,"%s %d %c", "one", 2, '3');

  printf("%s", str);
}
one 2 3








22.35.sprintf
22.35.1.sprintf