Input / Output

Q1:
Point out the correct statements about the program?
#include<stdio.h>

int main()
{
    FILE *fptr;
    char str[80];
    fptr = fopen('f1.dat', 'w');
    if(fptr == NULL)
        printf('Cannot open file');
    else
    {
        while(strlen(gets(str))>0)
        {
            fputs(str, fptr);
            fputs('\n', fptr);
        }
        fclose(fptr);
    }
    return 0;
}

A The code copies the content of one file to another

B The code writes strings that are read from the keyboard into a file.

C The code reads a file

D None of above

ANS:A - The code copies the content of one file to another

This program get the input string from the user through gets function and store it in the file f1.txt using fputs function.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.