Files and Streams
- How many parameters are available in the function setbuf?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
There are two parameters that are used in setbuf. They are stream and buffer.
- Which one is always faster in writing on C++?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
For the stand of file operations, writing to memory (RAM) is always faster than writing to the file on the disk directly.
- How many tests are available in read and write operations?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
There are two types of read and write tests. They are throughput in random reads and throughput in contiguous reads.
- What will act as a intermediate between i/o operations and physical file?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
A stream buffer is a block of data that acts as intermediary between the i/o operations and the physical file associated to the stream.
- What is the output of this program in text files?
#include <iostream>
int main ()
{
char buff[BUFSIZ];
FILE *ptr1, *ptr2;
ptr1 = fopen ("FirstFile.txt", "w");
ptr2 = fopen ("SecondFile.txt", "a");
setbuf ( ptr1 , buff );
fputs ("Buffered stream", ptr1);
fflush (ptr1);
setbuf ( ptr2 , NULL );
fputs ("Unbuffered stream", ptr2);
fclose (ptr1);
fclose (ptr2);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, the fopen will create the file and send the text to both of the files.