Пространства имён
Варианты
Действия

printf, fprintf, sprintf, snprintf

Материал из cppreference.com
< c | io

 
 
File input/output
Функции
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Доступ к файлам
Original:
File access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Прямой ввод / вывод
Original:
Direct input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fread
fwrite
Неформатированная ввода / вывода
Original:
Unformatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Форматированный ввод / вывод
Original:
Formatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
scanf
fscanf
sscanf
vscanf
vfscanf
vsscanf
(C99)
(C99)
(C99)
printf
fprintf
sprintf
snprintf



(C99)
vprintf
vfprintf
vsprintf
vsnprintf



(C99)
Позиционирование файла
Original:
File positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ftell
fgetpos
fseek
fsetpos
rewind
Обработка ошибок
Original:
Error handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
clearerr
feof
ferror
perror
Операции с файлами
Original:
Operations on files
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
remove
rename
tmpfile
tmpnam
 
Заголовочный файл <stdio.h>
int printf( const char *format, ... );
(1)
int fprintf( FILE *stream, const char *format, ... );
(2)
int sprintf( char *buffer, const char *format, ... );
(3)
int snprintf( char *buffer, int buf_size, const char *format, ... );
(4) (начиная с C99)
Загружает данные из данного места, преобразует их в строку символов эквиваленты и записывает результаты в различных поглотителей.
Original:
Loads the data from the given locations, converts them to character string equivalents and writes the results to a variety of sinks.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Записывает результаты в stdout.
Original:
Writes the results to stdout.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Записывает результаты в файл потока stream.
Original:
Writes the results to a file stream stream.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Записывает результаты в buffer буквенная.
Original:
Writes the results to a character string buffer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Записывает результаты в buffer строку символов. В большинстве buf_size - 1 символов написаны. В результате символьная строка будет завершен нулевой символ, если buf_size равна нулю.
Original:
Writes the results to a character string buffer. At most buf_size - 1 characters are written. The resulting character string will be terminated with a null character, unless buf_size is zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Содержание

[править] Параметры

stream -
Поток выходной файл для записи
Original:
output file stream to write to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
buffer -
Указатель на строку символов для записи
Original:
pointer to a character string to write to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
buf_size -
до BUF_SIZE - 1 символов может быть написана, плюс нулевой символ
Original:
up to buf_size - 1 characters may be written, plus the null terminator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
format -
Указатель на завершающуюся нулем строку, определяющую многобайтовую, как интерпретировать эти данные.
Строка формата состоит из пробельных символов, без пробелов символы (кроме %) и спецификации преобразования. Каждая спецификация преобразования имеет следующий формат:
Original:
The format string consists of whitespace characters, non-whitespace characters (except %) and conversion specifications. Each conversion specification has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • вводный характер %
    Original:
    introductory % character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно) один или несколько флагов, которые изменяют поведение преобразования
    Original:
    (необязательно) one or more flags that modify the behavior of the conversion:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • -: результат преобразования влево на поле (по умолчанию это по правому краю)
    Original:
    -: the result of the conversion is left-justified within the field (by default it is right-justified)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • +: знак подписано преобразования всегда добавляется в результате преобразования (по умолчанию результат предшествует минус только тогда, когда оно отрицательное)
    Original:
    +: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ' Пространстве: если в результате подписанного преобразования начинается не с знаковый характер, или пусто, пространство добавляется к результату. Он игнорируется, если + флаг присутствует.
    Original:
    space: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • #:' альтернативные формы преобразование не выполняется. См. таблицу ниже для точного эффекта.
    Original:
    # : alternative form of the conversion is performed. See the table below for exact effects.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 0: для целочисленных и плавающих преобразования точкой, ведущих нулей используются для площадки на поле вместо' космических символов. Для чисел с плавающей запятой игнорируется если точность явно указано. Для других преобразований с помощью этого флага приводит к неопределенному поведению. Он игнорируется, если - флаг присутствует.
    Original:
    0 : for integer and floating point number conversions, leading zeros are used to pad the field instead of space characters. For floating point numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if - flag is present.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно) целое значение или *, который определяет минимальную ширину поля. В результате заполняется пространство' символов (по умолчанию), если требуется, слева, когда по правому краю, или справа, если по левому краю. В случае, когда * используется, ширина определяется дополнительным аргументом типа int. Если значение аргумента отрицательно, это приводит с - флаг определенных и положительных ширину поля.
    Original:
    (необязательно) integer value or * that specifies minimum field width. The result is padded with space characters (by default), if required, on the left when right-justified, or on the right if left-justified. In the case when * is used, the width is specified by an additional argument of type int. If the value of the argument is negative, it results with the - flag specified and positive field width.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно) . следует целое число или *, которая определяет точность' преобразования. В случае, когда * используется,' точностью определяется дополнительным аргументом типа int. Если значение этого аргумента отрицательно, оно игнорируется. См. таблицу ниже для точного эффекта точности'.
    Original:
    (необязательно) . followed by integer number or * that specifies precision of the conversion. In the case when * is used, the precision is specified by an additional argument of type int. If the value of this argument is negative, it is ignored. See the table below for exact effects of precision.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно)' длина модификатора, который определяет размер аргумента
    Original:
    (необязательно) length modifier that specifies the size of the argument
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Преобразование формата
    Original:
    conversion format specifier
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Следующие спецификаторы формата доступны
Original:
The following format specifiers are available:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Argument type
length modifier hh h (none) l ll j z t L
% writes literal %. The full conversion specification must be %%. N/A N/A N/A N/A N/A N/A N/A N/A N/A
c writes a single character N/A N/A char wchar_t N/A N/A N/A N/A N/A
s writes a character string N/A N/A char* wchar_t* N/A N/A N/A N/A N/A
d
i
преобразует "десятичное число подписан в стиле [-] DDDD.
Original:
converts a signed decimal integer' in the style [-]dddd.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются. По умолчанию точность 1.
Original:
Precision specifies the minimum number of digits to appear. The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
signed char
signed short
signed int
signed long
signed long long
N/A
o
преобразует подписан 'восьмеричное целое' в стиле [-] оооо..
Original:
converts a signed octal integer in the style [-]oooo.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются. По умолчанию точность 1.
Original:
Precision specifies the minimum number of digits to appear. The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' точность возрастает, если необходимо, чтобы написать одну нуля.
Original:
In the alternative implementation precision is increased if necessary, to write one leading zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В том случае, если оба преобразованное значение и точность являются 0, одна 0 написано.
Original:
In that case if both the converted value and the precision are 0, single 0 is written.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A
x
X
преобразует "шестнадцатеричное целое подписан в стиле [-] HHHH.
Original:
converts a signed hexadecimal integer' in the style [-]hhhh.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для буквы x преобразования abcdef являются used.
Original:
For the x conversion letters abcdef are used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для буквы X преобразования ABCDEF являются used.
Original:
For the X conversion letters ABCDEF are used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются. По умолчанию точность 1.
Original:
Precision specifies the minimum number of digits to appear. The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' 0x или 0X является приставкой к результатам, если преобразованное значение отлично от нуля.
Original:
In the alternative implementation 0x or 0X is prefixed to results if the converted value is nonzero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A
u
преобразует 'беззнаковое десятичное число в стиле' DDDD.
Original:
converts an unsigned decimal integer in the style dddd.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются.
Original:
Precision specifies the minimum number of digits to appear.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность 1.
Original:
The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unsigned char
unsigned short
unsigned int
unsigned long
unsigned long long
N/A
f
F
преобразует 'число с плавающей точкой' в десятичной системе счисления в стиле [-] ddd.ddd.
Original:
converts floating-point number to the decimal notation in the style [-]ddd.ddd.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр после десятичной точки характером.
Original:
Precision specifies the minimum number of digits to appear after the decimal point character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность 6.
Original:
The default precision is 6.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' символ десятичной точки написано, даже если нет следующих цифр.
Original:
In the alternative implementation decimal point character is written even if no digits follow it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
double
double
N/A N/A N/A N/A
long double
e
E
преобразует 'число с плавающей точкой' в десятичной системе счисления показателем.
Original:
converts floating-point number to the decimal exponent notation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования e [-]? D.ddd' e дд является used.
Original:
For the e conversion style [-]d.ddde±dd is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования E [-]? D.ddd' E дд является used.
Original:
For the E conversion style [-]d.dddE±dd is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Показатель содержит по крайней мере две цифры, более цифр используются только при необходимости.
Original:
The exponent contains at least two digits, more digits are used only if necessary.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если значение 0, показатель также 0.
Original:
If the value is 0, the exponent is also 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр после десятичной точки характером.
Original:
Precision specifies the minimum number of digits to appear after the decimal point character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность 6.
Original:
The default precision is 6.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' символ десятичной точки написано, даже если нет следующих цифр.
Original:
In the alternative implementation decimal point character is written even if no digits follow it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A N/A N/A N/A N/A
a
A
преобразует 'число с плавающей точкой' в шестнадцатеричном показателем.
Original:
converts floating-point number to the hexadecimal exponent notation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования a [-]? 0x' h.hhh p D является used.
Original:
For the a conversion style [-]0xh.hhhp±d is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования A [-]? 0X' h.hhh P D является used.
Original:
For the A conversion style [-]0Xh.hhhP±d is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Первая цифра шестнадцатеричной является 0, если аргумент не является нормированным значением с плавающей точкой.
Original:
The first hexadecimal digit is 0 if the argument is not a normalized floating point value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если значение 0, показатель также 0.
Original:
If the value is 0, the exponent is also 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр после десятичной точки характером.
Original:
Precision specifies the minimum number of digits to appear after the decimal point character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность достаточна для точного представления значения.
Original:
The default precision is sufficient for exact representation of the value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' символ десятичной точки написано, даже если нет следующих цифр.
Original:
In the alternative implementation decimal point character is written even if no digits follow it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A N/A N/A N/A N/A
g
G
преобразует "число с плавающей точкой в десятичную или десятичной экспоненты обозначение в зависимости от величины и точности'.
Original:
converts floating-point number to decimal or decimal exponent notation depending on the value and the precision.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля g преобразования преобразования в стиле e или f будет performed.
Original:
For the g conversion style conversion with style e or f will be performed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля G преобразования преобразования в стиле E или F будет performed.
Original:
For the G conversion style conversion with style E or F will be performed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Пусть P равной точности, если отлична от нуля, 6 если точность не указана, или 1 если точность равна 0. Тогда, если преобразование в стиле E будет иметь показатель X
Original:
Let P equal the precision if nonzero, 6 if the precision is not specified, or 1 if the precision is 0. Then, if a conversion with style E would have an exponent of X:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • если P> X ≥ -4, преобразование в стиле f или F и точность P - 1 - X.
    Original:
    if P > X ≥ −4, the conversion is with style f or F and precision P − 1 − X.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • В противном случае преобразование в стиле e или E и точность P - 1.
    Original:
    otherwise, the conversion is with style e or E and precision P − 1.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Если' альтернативного представления просил нули удаляются, а также символ десятичной точки удаляются, если не дробная часть остается.
Original:
Unless alternative representation is requested the trailing zeros are removed, also the decimal point character is removed if no fractional part is left.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A N/A N/A N/A N/A
n
возвращает "число записанных символов до сих пор этого вызова функции.
Original:
returns the number of characters written' so far by this call to the function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В результате' написаны на значение, на которую указывает аргумент.
Original:
The result is written to the value pointed to by the argument.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Полная спецификация должна быть %n.
Original:
The complete specification must be %n.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A int* N/A N/A N/A N/A N/A N/A
p writes an implementation defined character sequence defining a pointer. N/A N/A void* N/A N/A N/A N/A N/A N/A
'Примечание'
Original:
Notes:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Плавающей точкой функции преобразования конвертировать бесконечности inf или infinity. Какой из них используется реализации defined.
Original:
The floating point conversion functions convert infinity to inf or infinity. Which one is used is implementation defined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Не-а-число преобразуется в nan или nan(char_sequence). Какой из них используется реализации defined.
Original:
Not-a-number is converted to nan or nan(char_sequence). Which one is used is implementation defined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Преобразования F, E, G, A выход INF, INFINITY, NAN вместо.
Original:
The conversions F, E, G, A output INF, INFINITY, NAN instead.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
pointer to a null-terminated multibyte string specifying how to interpret the data.
Строка формата состоит из пробельных символов, без пробелов символы (кроме %) и спецификации преобразования. Каждая спецификация преобразования имеет следующий формат:
Original:
The format string consists of whitespace characters, non-whitespace characters (except %) and conversion specifications. Each conversion specification has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • вводный характер %
    Original:
    introductory % character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно) один или несколько флагов, которые изменяют поведение преобразования
    Original:
    (необязательно) one or more flags that modify the behavior of the conversion:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • -: результат преобразования влево на поле (по умолчанию это по правому краю)
    Original:
    -: the result of the conversion is left-justified within the field (by default it is right-justified)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • +: знак подписано преобразования всегда добавляется в результате преобразования (по умолчанию результат предшествует минус только тогда, когда оно отрицательное)
    Original:
    +: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ' Пространстве: если в результате подписанного преобразования начинается не с знаковый характер, или пусто, пространство добавляется к результату. Он игнорируется, если + флаг присутствует.
    Original:
    space: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • #:' альтернативные формы преобразование не выполняется. См. таблицу ниже для точного эффекта.
    Original:
    # : alternative form of the conversion is performed. See the table below for exact effects.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 0: для целочисленных и плавающих преобразования точкой, ведущих нулей используются для площадки на поле вместо' космических символов. Для чисел с плавающей запятой игнорируется если точность явно указано. Для других преобразований с помощью этого флага приводит к неопределенному поведению. Он игнорируется, если - флаг присутствует.
    Original:
    0 : for integer and floating point number conversions, leading zeros are used to pad the field instead of space characters. For floating point numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if - flag is present.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно) целое значение или *, который определяет минимальную ширину поля. В результате заполняется пространство' символов (по умолчанию), если требуется, слева, когда по правому краю, или справа, если по левому краю. В случае, когда * используется, ширина определяется дополнительным аргументом типа int. Если значение аргумента отрицательно, это приводит с - флаг определенных и положительных ширину поля.
    Original:
    (необязательно) integer value or * that specifies minimum field width. The result is padded with space characters (by default), if required, on the left when right-justified, or on the right if left-justified. In the case when * is used, the width is specified by an additional argument of type int. If the value of the argument is negative, it results with the - flag specified and positive field width.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно) . следует целое число или *, которая определяет точность' преобразования. В случае, когда * используется,' точностью определяется дополнительным аргументом типа int. Если значение этого аргумента отрицательно, оно игнорируется. См. таблицу ниже для точного эффекта точности'.
    Original:
    (необязательно) . followed by integer number or * that specifies precision of the conversion. In the case when * is used, the precision is specified by an additional argument of type int. If the value of this argument is negative, it is ignored. See the table below for exact effects of precision.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (необязательно)' длина модификатора, который определяет размер аргумента
    Original:
    (необязательно) length modifier that specifies the size of the argument
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Преобразование формата
    Original:
    conversion format specifier
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Следующие спецификаторы формата доступны
Original:
The following format specifiers are available:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Argument type
length modifier hh h (none) l ll j z t L
% writes literal %. The full conversion specification must be %%. N/A N/A N/A N/A N/A N/A N/A N/A N/A
c writes a single character N/A N/A char wchar_t N/A N/A N/A N/A N/A
s writes a character string N/A N/A char* wchar_t* N/A N/A N/A N/A N/A
d
i
преобразует "десятичное число подписан в стиле [-] DDDD.
Original:
converts a signed decimal integer' in the style [-]dddd.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются. По умолчанию точность 1.
Original:
Precision specifies the minimum number of digits to appear. The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
signed char
signed short
signed int
signed long
signed long long
N/A
o
преобразует подписан 'восьмеричное целое' в стиле [-] оооо..
Original:
converts a signed octal integer in the style [-]oooo.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются. По умолчанию точность 1.
Original:
Precision specifies the minimum number of digits to appear. The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' точность возрастает, если необходимо, чтобы написать одну нуля.
Original:
In the alternative implementation precision is increased if necessary, to write one leading zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В том случае, если оба преобразованное значение и точность являются 0, одна 0 написано.
Original:
In that case if both the converted value and the precision are 0, single 0 is written.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A
x
X
преобразует "шестнадцатеричное целое подписан в стиле [-] HHHH.
Original:
converts a signed hexadecimal integer' in the style [-]hhhh.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для буквы x преобразования abcdef являются used.
Original:
For the x conversion letters abcdef are used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для буквы X преобразования ABCDEF являются used.
Original:
For the X conversion letters ABCDEF are used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются. По умолчанию точность 1.
Original:
Precision specifies the minimum number of digits to appear. The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' 0x или 0X является приставкой к результатам, если преобразованное значение отлично от нуля.
Original:
In the alternative implementation 0x or 0X is prefixed to results if the converted value is nonzero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A
u
преобразует 'беззнаковое десятичное число в стиле' DDDD.
Original:
converts an unsigned decimal integer in the style dddd.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр появляются.
Original:
Precision specifies the minimum number of digits to appear.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность 1.
Original:
The default precision is 1.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если оба преобразованное значение и точность являются 0 в результате преобразования никакие символы.
Original:
If both the converted value and the precision are 0 the conversion results in no characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unsigned char
unsigned short
unsigned int
unsigned long
unsigned long long
N/A
f
F
преобразует 'число с плавающей точкой' в десятичной системе счисления в стиле [-] ddd.ddd.
Original:
converts floating-point number to the decimal notation in the style [-]ddd.ddd.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр после десятичной точки характером.
Original:
Precision specifies the minimum number of digits to appear after the decimal point character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность 6.
Original:
The default precision is 6.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' символ десятичной точки написано, даже если нет следующих цифр.
Original:
In the alternative implementation decimal point character is written even if no digits follow it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
double
double
N/A N/A N/A N/A
long double
e
E
преобразует 'число с плавающей точкой' в десятичной системе счисления показателем.
Original:
converts floating-point number to the decimal exponent notation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования e [-]? D.ddd' e дд является used.
Original:
For the e conversion style [-]d.ddde±dd is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования E [-]? D.ddd' E дд является used.
Original:
For the E conversion style [-]d.dddE±dd is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Показатель содержит по крайней мере две цифры, более цифр используются только при необходимости.
Original:
The exponent contains at least two digits, more digits are used only if necessary.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если значение 0, показатель также 0.
Original:
If the value is 0, the exponent is also 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр после десятичной точки характером.
Original:
Precision specifies the minimum number of digits to appear after the decimal point character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность 6.
Original:
The default precision is 6.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' символ десятичной точки написано, даже если нет следующих цифр.
Original:
In the alternative implementation decimal point character is written even if no digits follow it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A N/A N/A N/A N/A
a
A
преобразует 'число с плавающей точкой' в шестнадцатеричном показателем.
Original:
converts floating-point number to the hexadecimal exponent notation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования a [-]? 0x' h.hhh p D является used.
Original:
For the a conversion style [-]0xh.hhhp±d is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования A [-]? 0X' h.hhh P D является used.
Original:
For the A conversion style [-]0Xh.hhhP±d is used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Первая цифра шестнадцатеричной является 0, если аргумент не является нормированным значением с плавающей точкой.
Original:
The first hexadecimal digit is 0 if the argument is not a normalized floating point value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Если значение 0, показатель также 0.
Original:
If the value is 0, the exponent is also 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
' Precision определяет минимальное количество цифр после десятичной точки характером.
Original:
Precision specifies the minimum number of digits to appear after the decimal point character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
По умолчанию точность достаточна для точного представления значения.
Original:
The default precision is sufficient for exact representation of the value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В реализации альтернативных' символ десятичной точки написано, даже если нет следующих цифр.
Original:
In the alternative implementation decimal point character is written even if no digits follow it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A N/A N/A N/A N/A
g
G
преобразует "число с плавающей точкой в десятичную или десятичной экспоненты обозначение в зависимости от величины и точности'.
Original:
converts floating-point number to decimal or decimal exponent notation depending on the value and the precision.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля g преобразования преобразования в стиле e или f будет performed.
Original:
For the g conversion style conversion with style e or f will be performed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля G преобразования преобразования в стиле E или F будет performed.
Original:
For the G conversion style conversion with style E or F will be performed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Пусть P равной точности, если отлична от нуля, 6 если точность не указана, или 1 если точность равна 0. Тогда, если преобразование в стиле E будет иметь показатель X
Original:
Let P equal the precision if nonzero, 6 if the precision is not specified, or 1 if the precision is 0. Then, if a conversion with style E would have an exponent of X:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • если P> X ≥ -4, преобразование в стиле f или F и точность P - 1 - X.
    Original:
    if P > X ≥ −4, the conversion is with style f or F and precision P − 1 − X.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • В противном случае преобразование в стиле e или E и точность P - 1.
    Original:
    otherwise, the conversion is with style e or E and precision P − 1.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Если' альтернативного представления просил нули удаляются, а также символ десятичной точки удаляются, если не дробная часть остается.
Original:
Unless alternative representation is requested the trailing zeros are removed, also the decimal point character is removed if no fractional part is left.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Для стиля преобразования бесконечность и не-число см. примечания.
Original:
For infinity and not-a-number conversion style see notes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A N/A N/A N/A N/A
n
возвращает "число записанных символов до сих пор этого вызова функции.
Original:
returns the number of characters written' so far by this call to the function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
В результате' написаны на значение, на которую указывает аргумент.
Original:
The result is written to the value pointed to by the argument.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Полная спецификация должна быть %n.
Original:
The complete specification must be %n.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A int* N/A N/A N/A N/A N/A N/A
p writes an implementation defined character sequence defining a pointer. N/A N/A void* N/A N/A N/A N/A N/A N/A
'Примечание'
Original:
Notes:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Плавающей точкой функции преобразования конвертировать бесконечности inf или infinity. Какой из них используется реализации defined.
Original:
The floating point conversion functions convert infinity to inf or infinity. Which one is used is implementation defined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Не-а-число преобразуется в nan или nan(char_sequence). Какой из них используется реализации defined.
Original:
Not-a-number is converted to nan or nan(char_sequence). Which one is used is implementation defined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Преобразования F, E, G, A выход INF, INFINITY, NAN вместо.
Original:
The conversions F, E, G, A output INF, INFINITY, NAN instead.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
... -
аргументы, определяющие данные для печати
Original:
arguments specifying data to print
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Возвращаемое значение

1-3)
Количество символов в случае успеха или отрицательное значение, если произошла ошибка.
Original:
number of characters written if successful or negative value if an error occurred.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Количество символов в случае успеха или отрицательное значение, если произошла ошибка. Если в результате строка остается усеченным из-за предела buf_size, функция возвращает общее количество символов (не включая завершающий нулевой байт), которая была бы написана, если лимит не был навязан.
Original:
number of characters written if successful or negative value if an error occurred. If the resulting string gets truncated due to buf_size limit, function returns the total number of characters (not including the terminating null-byte) which would have been written, if the limit was not imposed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Пример

#include <stdio.h>
 
int main()
{
    printf("Strings:\n");
    const char* s = "Hello";
    printf("\t.%10s.\n\t.%-10s.\n\t.%*s.\n", s, s, 10, s);
 
    printf("Characters:\t%c %%\n", 65);
 
    printf("Integers\n");
    printf("Decimal:\t%i %d %.6i %i %.0i %+i %u\n", 1, 2, 3, 0, 0, 4, -1);
    printf("Hexadecimal:\t%x %x %X %#x\n", 5, 10, 10, 6);
    printf("Octal:\t%o %#o %#o\n", 10, 10, 4);
 
    printf("Floating point\n");
    printf("Rounding:\t%f %.0f %.32f\n", 1.5, 1.5, 1.3);
    printf("Padding:\t%05.2f %.2f %5.2f\n", 1.5, 1.5, 1.5);
    printf("Scientific:\t%E %e\n", 1.5, 1.5);
    printf("Hexadecimal:\t%a %A\n", 1.5, 1.5);
}

Вывод:

Strings:
    .     Hello.
    .Hello     .
    .     Hello.
Characters:     A %
Integers
Decimal:        1 2 000003 0  +4 4294967295
Hexadecimal:    5 a A 0x6
Octal:          12 012 04
Floating point
Rounding:       1.500000 2 1.30000000000000004440892098500626
Padding:        01.50 1.50  1.50
Scientific:     1.500000E+00 1.500000e+00
Hexadecimal:    0x1.8p+0 0X1.8P+0

[править] См. также

отпечатки отформатировать вывод stdout, поток файла или buffer
использованием переменного списка аргументов
Original:
prints formatted output to stdout, a file stream or a buffer
using variable argument list
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(функция) [edit]
пишет символьная строка в файле поток
Original:
writes a character string to a file stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(функция) [edit]
читается форматированный ввод из stdin, поток файл или буфер
Original:
reads formatted input from stdin, a file stream or a buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(функция) [edit]
C++ документация для printf, fprintf, sprintf, snprintf