File Processing Flashcards
Files are used for data persistence which is…
Permanent retention of data
How do computers store files?
Secondary storage devices
What is a file?
A sequence of bytes
Files end with
End-of-file marker
Or
Specific byte number recorded in data structure
What happens when a file is opened?
An object is created with associated stream
Which headers must be included for file processing?
<iostream> and <fstream>
</fstream></iostream>
<fstream>'s typedef aliases enables....
</fstream>
char output to files
C++ structure on file
Not imposed
When an ____________ object is created, a file can be opened for output
ofstream
What happens to existing files opened with iOS::out?
They are truncated
How can you add to the end of a file?
ios::app
ofstream objects must be created while opening a file
No, it can be attached later
What does overloaded operator ! do for a stream?
Determines if it is opened correctly
What is the failbit for cin?
End-of-file indicator
How can you close a stream object?
Use close member function or stream object’s destructor
Why do files store data?
So it can be received for processing when needed
When are objects of ifstream opened for input?
By default
How do you retrieve data sequentially from a file?
Read from the beginning until desired data is found
What is the file position pointer for ifstream?
seekg
What is the file position pointer for ostream?
seekp
How can you indicate the byte number in a file where next input will occur?
get pointer for istream
put pointer for ostream
Which three seek directions can seekg indicate?
ios::beg
ios::cur
ios::end
File position pointer specifies the location as number of bytes from file’s start location or it’s….
offset
What member functions return the current locations of the get and put pointers?
tellg and tellp
Why can you not modify data that is formatted and written to a sequential file?
Record sizes can vary
What is an instant access application?
When a particular record must be located immediately
What makes instant access to file possible?
random access files
How do you format files for random access?
Same size, fixed length records
What are the advantages of random access files?
Data can be inserted, updated, or deleted without rewriting the entire file
Which ostream member function outputs a fixed number of bytes, beginning at a specific location in memory, to a stream?
write
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?
read
How does function write find location to output?
Takes const char* of bytes
How to convert a pointer of one type to a pointer of an unrelated type?
reinterpret_cast
How can unformatted data be compiled and executed?
Must be on a system compatible with the program that wrote the data
Objects of class string do not have uniform size, instead they use….
Dynamically allocated memory