Unit 3 CS 36 Flashcards

1
Q

What are streams?

A

Streams are data buffers/collectors. The three different streams are input(keyboard), output(message or outcome after running the program), and error (message regarding wrongly written code or syntax issues). Both error and output are based on screen, and input is by keyboard

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

How can streams be manipulated?

A

Using the stdin, stdout and stderr functions from the standard library (standard in, out, and error)

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

How do we work with files in C?

A

We have to change the input and output stream files using stdin and stdout.

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

What are the two different ways to input and output to files?

A

Sequential and Random-Access

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

What are the two functions to manipulate files?

A

fgets() and fputs()

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

true or false: each file needs it’s own pointer?

A

true. to initialize a file pointer, you have to do FILE *cPtr; to point to a file structure

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

What does the fopen function do?

A

It takes a file name and a mode as it’s arguments (ex: fopen(“file.exe”, “w”); in this case, the mode of the file is write). If this file doesn’t exist, fopen creates a new file with that given name “file.exe”

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

File

A

collection of data or information that is stored on a computer’s storage. For example, a hard drive or a USB stick

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

What happens if fopen is equal to NULL?

A

That means there is an error regarding opening the file

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

True or false, you always have to open a file before you manipulate the file?

A

True, you have to use fopen and then manipulate the file, and when you are finally done manipulating everything, you close using fclose(). Remember, fopen is equal to the address of a file, meaning that you must use a pointer of a file to store this value

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

Let’s say you make a pointer (FILE *cPtr) and then you do cPtr = fopen(“file name”, “mode”), what does the pointer equal to if this assignment does not work?

A

It is equal to NULL

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

EOF

A

End of File value that tells you you have reached the end of the file that you are reading

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

feof(stdin)

A

looks for EOF (end of file) indicator

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

Random-Access Files

A

This is when a file is opened through the “wb” mode instead of “w” or “r” (write or read, and this represents binary write) and then a structure is used to fill in certain values. The file is represented in binary form

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

instance

A

The variable of a structure

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

a random access file is useful when you are using a struct to write values into the file

A

Yes

17
Q

Review how fwrite works when the file is in binary write mode

A

Yes

18
Q

“wb” vs “rb+”

A

wb is used create files and write new information, whereas rb+ is useful for updating information among the already created random-access file

18
Q

True or False, is the correct format for scanf like this: scanf(“%d”, &value1);

A

Yes, you must include a percentage sign before the type of data, as well as an ampersand next to the value in scanf

19
Q

ListedNode

A

This is a linked list that is created when you have a structure with a self-referential pointer, and a char variable within the structure.