Files and Streams


  1. How many parameters are available in the function setbuf?











  1. 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.


  1. Which one is always faster in writing on C++?











  1. 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.



  1. How many tests are available in read and write operations?











  1. 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.


  1. What will act as a intermediate between i/o operations and physical file?











  1. 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.



  1. 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;
    }











  1. 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.