by Default, All The Files in C++ Are Opened in - Mode
by Default, All The Files in C++ Are Opened in - Mode
3. Which function is used in C++ to get the current position of file pointer in a file?
a) tell_p()
b) get_pos()
c) get_p()
d) tell_pos()
A. Returns true if a file open for reading has reached the next character.
B. Returns true if a file open for reading has reached the next word.
C. Returns true if a file open for reading has reached the end.
D. Returns true if a file open for reading has reached the middle.
{
FILE *fp;
char x[1024];
fp = fopen("find.txt", "r"); // "ayushjain and prateek"
x[0] = getc(fp);
fseek(fp, 0, SEEK_END);
fseek(fp, -7L, SEEK_CUR);
fgets(x, 6, fp);
puts(x);
return 0;
}
A. ayushj
B. yushja
C. ayushja
D. prate
9. The __________ built in class can be used to create files and read information
from them into memory.
A. instream
B. ifstream
C. ofstream
D. istream
12. 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
13. To perform File I/O operations, we must use _____________ header file.
A. < ifstream>
B. < ofstream>
C. < fstream>
D. Any of these
16. In order, the three-step process of using a file in a C++ program involves:
A. Name the file, open the file, and delete the file
B. Insert a diskette, open a file, and remove the disk
C. Open the existing file, read/write data, close the file
D. Create the file contents, close the file, and name the file
17. Which of the following is used to Open a file for output and move the
read/write control to the end of the file ?
A. ios::ate
B. ios::at
C. ios::ann
D. ios::end