File operations Flashcards

1
Q

What is the library we want to use?

A

include

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

How do we make a stream? What is a stream?

A

std::ofstream output;

> This is used to declare a connection (object) to a file

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

How do you open a file to write to?

A

output.open(“output.txt”);

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

How do you check to see if the file opened?

A

output.is_open()

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

How do you stop writing to a file?

A

output.close();

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

How do you add to a file without overwriting data?

A

using ‘std::fstream::app output;’

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

how do you write to a file?

A

output &laquo_space;“string” &laquo_space;std::endl

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

How do you make a stream to read a file?

A

std::ifstream input;

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

How do you check a stream to read a file has opened?

A

input.is_open();

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

How do you read from a file?

A

std::string input_string;

input&raquo_space; input_string;

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

How do you read until a character?

A

getline(input, input_string, ‘,’);

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

How do you read until the end of a line?

A

getline(input, input_string);

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