fprintf
Writes data to a file.
Syntax
fprintf(format, v1, ... , vn)
fprintf(fid, format, v1, ... , vn)
R = fprintf(fid, format, v1, ... , vn)
Input argument
fid - a file descriptor
format - a string describing the format to used_function.
v1, ... , vn - data to convert and print according to the previous format parameter.
Output argument
R - an integer value: number of bytes that fprintf write.
Description
Write data in text form to the file specified by the file descriptor fid.
characters encoding uses fopen parameter.
If fid equals 1 redirection in stdout.
If fid equals 2 redirection in stderr.
The format follows C fprintf syntax.
Integer
%i
base 10
Integer signed
%d
base 10
Integer unsigned
%u
base 10
Integer
%o
Octal (base 8)
Integer
%x
Hexadecimal (lowercase)
Integer
%X
Hexadecimal (uppercase)
Floating-point number
%f
Fixed-point notation
Floating-point number
%e
Exponential notation (lowercase)
Floating-point number
%E
Exponential notation (uppercase)
Floating-point number
%g
Exponential notation (compact format, lowercase)
Floating-point number
%G
Exponential notation (compact format, uppercase)
Character
%c
Single character
String
%s
Character vector.
To display a percent sign, you need to use a double percent sign (%%) in the format string.
Examples
How to use backspace
Display a percent sign
See also
History
1.0.0
initial version
Author
Allan CORNET
Last updated