Formatting of Inputs/Outputs Flashcards

1
Q

format short

A

4 digits after decimal, default format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

format long

A

14 digits after decimal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

format short e

A

5 digits plus exponent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

format short g

A

5 total digits with or without exponent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

format bank

A

dollars and cents format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

format hex

A

hexadecimal display of bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

format rat

A

approximate ratio of small integers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

format compact

A

suppress extra line feeds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

format loose

A

restore extra line feeds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

format +

A

only signs are printed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

fprintf

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

%f

A

fixed point notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

%e

A

exponential notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

%d

A

decimal notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

%g

A

shortest form, %f or %e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

%c

A

characters shown on at the time

17
Q

%s

A

string of characters

18
Q

\n

A

linefeed: needed at the end of format string to start a new line

19
Q

\r

A

carriage return (similar to linefeed \n)

20
Q

\t

A

tab

21
Q

\b

A

backspace

22
Q

fopen

A

file_id = fopen(filename,permission)

opens file to read or save

23
Q

file_id

A

file_id = fopen(filename,permission)

identifier of text file, positive integer if file successfully opens, -1 if fopen fails

24
Q

permission

A

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)

25
Q

status

A

fclose(file_id)

=0 if file is successfully closed, -1 if fclose fails

26
Q

sprintf

A

write formatted data to string

27
Q

fscanf

A

reads formatted data into a matrix using conversion formats such as %d for integers, %s for strings, and %f for floats (doubles

28
Q

textscan

A

reads text data from a file and stores it in a cell array

29
Q

fget1 and fgets

A

read strings from a file one line at a time

fgets keeps the newline character if there is one at the end of the line, whereas the fget1 function gets rid of it

30
Q

feof( )

A

f End Of File

returns logical true if end of file has been reached, or logical false if not

31
Q

procedure for reading from files into strings

A
  1. open the file, check if opening was successful
  2. if opened successfully, loop until the end of file for each line:
    read line into a string
    manipulate the data
  3. close file, check if closing was successful