Formatting of Inputs/Outputs Flashcards
format short
4 digits after decimal, default format
format long
14 digits after decimal
format short e
5 digits plus exponent
format short g
5 total digits with or without exponent
format bank
dollars and cents format
format hex
hexadecimal display of bits
format rat
approximate ratio of small integers
format compact
suppress extra line feeds
format loose
restore extra line feeds
format +
only signs are printed
fprintf
writes data in user specified format, or displays data in command window
fprintf(format_string, variables)
% indicates where array is inserted into string, followed by conversion characters
%f
fixed point notation
%e
exponential notation
%d
decimal notation
%g
shortest form, %f or %e
%c
characters shown on at the time
%s
string of characters
\n
linefeed: needed at the end of format string to start a new line
\r
carriage return (similar to linefeed \n)
\t
tab
\b
backspace
fopen
file_id = fopen(filename,permission)
opens file to read or save
file_id
file_id = fopen(filename,permission)
identifier of text file, positive integer if file successfully opens, -1 if fopen fails
permission
file_id = fopen(filename,permission)
string specifying mode in which the file is opened
‘r’ opens for reading only
‘r+’ for reading and writing
‘w’ delete contents of existing file and open for writing only
‘w+’ open for reading and writing
‘a’ open existing file or create new only for the end of the file
‘rt’(‘wt’ and ‘at’) specify that the file is opened in text mode
‘rb’(‘wb’ and ‘ab’) specify that the file is opened in binary mode (default)