When a File Is Opened, the File Stream Object's "Read Position" Is


Problem 1

What capability does the fstream data type provide that the ifstream and ofstream
data types practice non?

Problem 2

Which file access flag do you use to open a file when y'all want all output written to
the stop of the file's existing contents?

Problem 3

Assume that the file data.txt already exists, and the following statement executes. What happens to the file?
fstream file("information.txt", ios::out);

Problem iv

How do y'all combine multiple file access flags when opening a file?

Problem 5

Should file stream objects exist passed to functions by value or by reference? Why?

Problem 6

Under what circumstances is a file stream object'due south ios::hardfail bit gear up? What member function reports the state of this bit?

Trouble 7

Under what circumstances is a file stream object'south ios::eofbit fleck set? What member
function reports the state of this chip?

Trouble 8

Nether what circumstances is a file stream object'southward ios::badbit bit set? What member
part reports the country of this bit?

Problem 9

How practise you read the contents of a text file that contains white space characters as part
of its data?

Problem x

What arguments practise you laissez passer to a file stream object's write member function?

Problem 11

What arguments do you lot pass to a file stream object's read member role?

Trouble 12

What type cast practise you apply to catechumen a pointer from ane type to another?

Problem 13

What is the difference between the seekg and seekp fellow member functions?

Problem 14

How practise you lot go the byte number of a file's current read position? How do you lot become the
byte number of a file's current write position?

Problem 15

If a program has read to the end of a file, what must you lot do before using either the
seekg or seekp member functions?

Problem 16

How do you decide the number of bytes that a file contains?

Problem 17

How practise you rewind a sequential-admission file?

Problem xviii

The ––––––––––– file stream data type is for output files, input files, or files that perform both input and output.

Problem 19

If a file fails to open, the file stream object volition be set to __________.

Trouble 20

The same formatting techniques used with __________ may also exist used when writing
data to a file.

Problem 21

The __________ function reads a line of text from a file.

Problem 22

The __________ member function reads a unmarried character from a file.

Problem 23

The __________ fellow member office writes a unmarried character to a file.

Problem 24

__________ files contain data that is unformatted and non necessarily stored equally ASCII
text.

Trouble 25

__________ files comprise information formatted as __________.

Problem 26

A(northward) __________ is a complete gear up of data about a single item and is made upwardly of __________.

Trouble 27

In C++, __________ provide a user-friendly manner to organize data into fields and records.

Problem 28

The __________ member function writes "raw" binary data to a file.

Trouble 29

The __________ member function reads "raw" binary data from a file.

Problem thirty

The __________ operator is necessary if you laissez passer annihilation other than a arrow-to-char
every bit the first argument of the ii functions mentioned in questions 26 and 27.

Problem 31

In __________ file access, the contents of the file are read in the order they appear in
the file, from the file's start to its end.

Problem 32

In __________ file access, the contents of a file may exist read in any gild.

Trouble 33

The __________ member role moves a file's read position to a specified byte in the
file.

Problem 34

The __________ member part moves a file'southward write position to a specified byte in
the file.

Problem 35

The __________ fellow member function returns a file's current read position.

Problem 36

The __________ fellow member function returns a file'due south current write position.

Problem 37

The __________ mode flag causes an offset to be calculated from the starting time of a
file.

Problem 38

The __________ mode flag causes an get-go to be calculated from the cease of a file.

Problem 39

The __________ mode flag causes an starting time to exist calculated from the current position
in the file

Problem 40

A negative offset causes the file's read or write position to be moved __________ in the
file from the position specified past the mode.

Problem 41

Write a statement that defines a file stream object named places. The object volition be
used for both output and input.

Problem 42

Write ii statements that employ a file stream object named people to open up a file named
people.dat. (Prove how to open the file with a member office and at the definition
of the file stream object.) The file should exist opened for output.

Problem 43

Write two statements that use a file stream object named pets to open a file named
pets.dat. (Show how to open up the file with a member function and at the definition
of the file stream object.) The file should be opened for input.

Problem 44

Write 2 statements that use a file stream object named places to open up a file named
places.dat. (Show how to open the file with a member function and at the definition
of the file stream object.) The file should exist opened for both input and output.

Trouble 45

Write a program segment that defines a file stream object named employees. The file
should be opened for both input and output (in binary fashion). If the file fails to open up,
the plan segment should brandish an fault bulletin.

Trouble 46

Write code that opens the file data.txt for both input and output, only first determines if the file exists. If the file does not exist, the code should create it, and then open it
for both input and output.

Problem 47

Write code that determines the number of bytes contained in the file associated with
the file stream object dataFile.

Problem 48

The infoFile file stream object is used to sequentially access data. The program has
already read to the end of the file. Write code that rewinds the file.

Problem 49

T F Different operating systems take different rules for naming files.

Problem 50

T F fstream objects are only capable of performing file output operations.

Problem 51

T F ofstream objects, past default, delete the contents of a file if it already exists
when opened.

Trouble 52

T F ifstream objects, by default, create a file if it doesn't exist when opened.

Problem 53

T F Several file admission flags may be joined past using the | operator.

Problem 54

T F A file may be opened in the definition of the file stream object.

Trouble 55

T F If a file is opened in the definition of the file stream object, no mode flags
may be specified.

Trouble 56

T F A file stream object's fail member office may be used to determine if the
file was successfully opened.

Trouble 57

T F The same output formatting techniques used with cout may also be used
with file stream objects.

Trouble 58

T F The >> operator expects information to be delimited by whitespace characters.

Problem 59

T F The getline member function can be used to read text that contains
whitespaces.

Trouble 60

T F It is not possible to accept more than 1 file open at in one case in a plan.

Problem 61

T F Binary files comprise unformatted data, not necessarily stored as text.

Problem 62

T F Binary is the default mode in which files are opened.

Trouble 63

T F The tellp fellow member function tells a file stream object which byte to move its
write position to.

Problem 64

T F It is possible to open a file for both input and output.

Problem 65

Each of the following programs or plan segments has errors. Find as many equally you can.
fstream file(ios: : in $|$ ios: : out ) file.open up ("info.dat"); if $(1 \mathrm{file})$
\{
cout $<<$ "Could not open up file. $\backslash northward "$
\}

Problem 66

Each of the following programs or program segments has errors. Find every bit many as you tin can.
ofstream file; file.open ("info.dat", ios: : in ) ;
if (file)
\{
cout $<<$ "Could not open up file. $\backslash n "$
\}

Problem 67

Each of the following programs or plan segments has errors. Find as many equally you can.
fstream file("info.dat") if ( ! file)
\{
cout $<<$ "Could not open file. $\ln ^{\prime \prime}$
\}

Problem 68

Each of the following programs or program segments has errors. Find every bit many equally you can.
fstream dataFile("info.dat", ios:in I ios:binary); $\operatorname{int} x=v$
dataFile $<<ten$

Problem 69

Each of the post-obit programs or program segments has errors. Detect as many as you tin can.
fstream dataFile ("info.dat", ios:in); char stuff [81] dataFile. get (stuff);

Problem seventy

Each of the following programs or programme segments has errors. Observe as many as you tin can.
fstream dataFile ("info.dat", ios: in); char stuff $[81]=$ "abcdefghijklmnopqrstuvwxyz" dataFile $\cdot$ put ( stuff) ;

Trouble 71

Each of the following programs or program segments has errors. Find as many as you tin can.
fstream dataFile ("info.dat", ios:out); struct Date
\{
int calendar month
int twenty-four hours; int twelvemonth;

\[
\text { Date } d t=\{4,2,98\}
\]
dataFile.write ( \&dt, sizeof(int));};

Problem 72

Each of the following programs or programme segments has errors. Detect every bit many equally you can.
fstream inFile("info.dat", ios:in); int $x$ inFile.seekp (five) inFile $>>x$

nortonsubjecould.blogspot.com

Source: https://www.numerade.com/books/chapter/advanced-file-operations-2/

0 Response to "When a File Is Opened, the File Stream Object's "Read Position" Is"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel