Files and Streams in C++

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/10

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards for file I/O in C++.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards

ofstream

Stream class to write to files. Requires the fstream library.

2
New cards

ifstream

Stream class to read from files. Requires the fstream library.

3
New cards

fstream

A class within the fstream library that can both read and write to files. It has no default mode, so it is better to use ifstream or ofstream instead.

4
New cards

open(filename, mode)

A stream object member function used to open a file with a specified filename and mode.

5
New cards

Mode (file I/O)

Specifies how a file should be opened (e.g., read, write, append). Modes can be combined using the | operator.

6
New cards

ios::app

File mode that appends new data to the end of an existing file.

7
New cards

ios::trunc

File mode that truncates the file, deleting the old content when opening.

8
New cards

myfile.fail()

A method to check if opening a file has failed.

9
New cards

myfile.close()

A method to close the connection to a file.

10
New cards

getline(stream, variable)

A function that reads a line from a stream (e.g., a file) until a delimiter (newline character) is encountered, and stores it in a variable.

11
New cards

Quoted Text

Can read strings with quotes from a text file.