Ch.6 Flashcards
What is the output of the following code?
char ch = ‘G’;
cout ≤≤ tolower(ch) ≤≤ endl;
the integer value of ‘g’
The command outFile.width(10) is used to
display the next value in at least 10 characters.
Which of the following function declarations will correctly pass an output stream to the function?
A) void display( ofstream& out);
B) void display( ostream out);
C) void display( ostream& out);
D) void display( ofstream out);
E) A and C
void display( ostream& out);
After a stream is opened, before it is used for input and output, it should be
checked to see if it opened correctly.
The command outFile.precision(2);
displays all floating point values sent to outFile with 2 decimal places.
If a file did not open correctly, you should
display an error message and take some suitable action such as exit.
Which function returns true if the character argument is a letter?
isalpha
To open a file with a user supplied name, you would need to store the name in a variable. If the file name was to have no more than 20 characters in it, which would be an appropriate declaration of the file name variable?
char filename[21];
Which of the following is the correct way to determine if a file stream named inFile opened correctly?
if( inFile.fail( ) )
A function that is associated with an object is called a ________ function.
member
What is wrong with the following code?
while( ! fileIn.eof( ) )
{
fileIn >> value;
fileout << value;
}
We have read past the end of the input file
If the name of the input file was in a variable named filename, which of the following is the correct way to open the input stream named inFile and associate it with this file?
inFile.open(filename);
The ifstream class is derived from the
istream class
ios::showpos is a flag that
always displays a + in front of positive integers.
The member function setf stands for
set the flags