Files Flashcards

1
Q

output file

A

a file that data is written to

type ofstream

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

input file

A

a file that data is read from

ifstream

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

What three steps are taken when a file is used by a program

A
  1. Open the file 2. Process the File 3. Close the File
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Open the file 2. Process the File 3. Close the File
A

include

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

2 things to happen before data can be written to or read from a file

A
  1. a file stream object must be created

2. The file must be opened and linked to the file stream object

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

code for creating a filestream object and linking the file to be open to the file stream object in order to open a file for input

A

ifstream inputFile;

inputFile.open(“Customers.txt”)

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

Define an ifstream object and name it inputFile

A

ifstream inputFile;

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

Call the inputFile object’s member function and pass the string “Customers.txt” as an argument

A

inputFile.open(“Customers.txt”)

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

An example of opening a file for output writing

A

ofstream outputFile;

outputFile.open(“Employees.txt”);

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

the file stream object’s close member function to call to close a file:

A

inputFile.close();

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

Example and format of writing a string literal to a file

A

outputFile &laquo_space;“I love C++ programming\n”;

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

Example and format of writing a string literal and the contents of a variable to a file

A

outputFile &laquo_space;“Price: “ &laquo_space;Price &laquo_space;endl;

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

example reading input from a file TO THE NEXT SPACE into the variable name

A

inputFile&raquo_space; name;

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

example reading input from a file TO THE NEXT LINE into the variable name

A

getline( inputfile, name)

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

read to the end of a file

A

while (!read.eof())

READING PART

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

how to tell if something was read by the input file

A

examplefile.good()

17
Q

how to include a fiile you made

A

include”examplefile”

18
Q

header guard code

A

endif

#ifndef UNIQUE_NAME_HERE
#define UNIQUE_NAME_HERE
19
Q

what is a file stream

A

A communication channel between the program and a file

20
Q

Which standard streams are created when a C++ program executes?

A

cin, cout

21
Q

is_open()

A

tests if the file is open

ex inputfile.is_open()