C Tutorial/stdio.h/sprintf — различия между версиями


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 10:32, 25 мая 2010

sprintf

Item Value Header file stdio.h Declaration int sprintf(char *buf, const char *format, ...); Function It is identical to printf() except that the output is a char array. Return returns 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);
}