File Handling

22.What is the output of this program?
Note:Includes all required header files

using namespace std;
int main ()
{
int l;
char * b;
ifstream i;
i.open ("find.txt", ios :: binary );
i.seekg (0, ios :: end);
l = i.tellg();
i.seekg (0, ios :: beg);
b = new char [l];
i.read (b, l);
i.close();
cout.write (b, l);
delete[] b;
return 0;
}

A. Error
B. find
C. This is find
D. Runtime error

View Answer


23.What is the output of this program?
Note:Includes all required header files

using namespace std;
int main ()
{
char fine, course;
cout << "Enter a word: ";
fine = cin.get();
cin.sync();
course = cin.get();
cout << fine << endl;
cout << course << endl;
return 0;
}

A. course
B. fine
C. Returns fine 2 letter or number from the entered word
D. None of the mentioned

View Answer


24. ios::trunc is used for ?

A. If the file is opened for output operations and it already existed, no action is taken.
B. If the file is opened for output operations and it already existed, then a new copy is created.
C. If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
D. None of the above

View Answer


25.In fopen(), the open mode "wx" is sometimes preferred "w" because.
i) Use of wx is more efficient.
ii) If w is used, old contents of file are erased and a new empty file is created. When wx is used, fopen() returns NULL if file already exists.

A. Only i
B. Only ii
C. Both i & ii
D. None of the above

View Answer


26.Which member function is used to determine whether the stream object is currently associated with a file?

A. is_open
B. Buf
C. String
D. None of the above

View Answer


27.getc() returns EOF when

A. End of files is reached
B. When getc() fails to read a character
C. Both A & B
D. None of the above

View Answer


28. fseek() should be preferred over rewind() mainly because

A. In rewind, there is no way to check if the operations completed successfully
B. rewind() doesn't work for empty files
C. rewind() doesn't work for empty file
D. All of the above

View Answer


29.Which function is used to position back from the end of file object?

A. Seekg
B. Seekp
C. Both seekg & seekp
D. None of the above

View Answer






Also check :


Discussion


* You must be logged in to add comment.