File Processing Flashcards

1
Q

Files are used for data persistence which is…

A

Permanent retention of data

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

How do computers store files?

A

Secondary storage devices

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

What is a file?

A

A sequence of bytes

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

Files end with

A

End-of-file marker
Or
Specific byte number recorded in data structure

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

What happens when a file is opened?

A

An object is created with associated stream

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

Which headers must be included for file processing?

A

<iostream> and <fstream>
</fstream></iostream>

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

<fstream>'s typedef aliases enables....
</fstream>

A

char output to files

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

C++ structure on file

A

Not imposed

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

When an ____________ object is created, a file can be opened for output

A

ofstream

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

What happens to existing files opened with iOS::out?

A

They are truncated

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

How can you add to the end of a file?

A

ios::app

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

ofstream objects must be created while opening a file

A

No, it can be attached later

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

What does overloaded operator ! do for a stream?

A

Determines if it is opened correctly

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

What is the failbit for cin?

A

End-of-file indicator

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

How can you close a stream object?

A

Use close member function or stream object’s destructor

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

Why do files store data?

A

So it can be received for processing when needed

17
Q

When are objects of ifstream opened for input?

A

By default

18
Q

How do you retrieve data sequentially from a file?

A

Read from the beginning until desired data is found

19
Q

What is the file position pointer for ifstream?

A

seekg

20
Q

What is the file position pointer for ostream?

A

seekp

21
Q

How can you indicate the byte number in a file where next input will occur?

A

get pointer for istream
put pointer for ostream

22
Q

Which three seek directions can seekg indicate?

A

ios::beg
ios::cur
ios::end

23
Q

File position pointer specifies the location as number of bytes from file’s start location or it’s….

A

offset

24
Q

What member functions return the current locations of the get and put pointers?

A

tellg and tellp

25
Q

Why can you not modify data that is formatted and written to a sequential file?

A

Record sizes can vary

26
Q

What is an instant access application?

A

When a particular record must be located immediately

27
Q

What makes instant access to file possible?

A

random access files

28
Q

How do you format files for random access?

A

Same size, fixed length records

29
Q

What are the advantages of random access files?

A

Data can be inserted, updated, or deleted without rewriting the entire file

30
Q

Which ostream member function outputs a fixed number of bytes, beginning at a specific location in memory, to a stream?

A

write

31
Q

Which istream member function inputs a fixed number of bytes from the specified stream to an area in memory beginning at a specified address specified by get file position pointer?

A

read

32
Q

How does function write find location to output?

A

Takes const char* of bytes

33
Q

How to convert a pointer of one type to a pointer of an unrelated type?

A

reinterpret_cast

34
Q

How can unformatted data be compiled and executed?

A

Must be on a system compatible with the program that wrote the data

35
Q

Objects of class string do not have uniform size, instead they use….

A

Dynamically allocated memory