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++ эксперт
snprintf: identical to sprintf() except that a maximum of num-1 characters will be stored
//Header file: #include <stdio.h>
//Declaration: int snprintf(char * restrict buf, size_t num, const char * restrict format, ...)
#include <stdio.h>
int main ()
{
char buffer [50];
int n, a=5, b=3;
n=snprintf (buffer, 5,"%d plus %d is %d", a, b, a+b);
printf ("[%s] is a %d char long string\n",buffer,n);
return 0;
}