C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Point Out Correct Statements (Q.No. 3)
Point out the correct statements about the program?

int main()
    FILE *fptr;
    char str[80];
    fptr = fopen("f1.dat", "w");
    if(fptr == NULL)
        printf("Cannot open file");
            fputs(str, fptr);
            fputs("\n", fptr);
    return 0;
The code copies the content of one file to another
The code writes strings that are read from the keyboard into a file.
The code reads a file
None of above
Answer: Option

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

3 comments Page 1 of 1.

Shivani said:   4 years ago
Shouldn't this run for infinite time because of the while loop? Please, anyone, tell me.

Pawan Kumar Singh said:   2 years ago
But without string.h how it possible sir?
It shows an error, right?

Piyush Agarwal said:   10 years ago
Without <string. H> how is this program even working?

Post your comments here:

Your comments will be displayed after verification.