Home Subjects C Programming File Handling

C Programming
File Handling

C language from basics to advanced placement prep

52 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 51–52 of 52
Topics in C Programming
Q.51 Medium File Handling
Which function writes formatted data to a file?
A fprintf()
B fwrite()
C fputs()
D fputc()
Correct Answer:  A. fprintf()
EXPLANATION

fprintf() writes formatted data to a file, similar to printf() but with a file pointer as the first argument.

Test
Q.52 Medium File Handling
What does fgets() function do?
A Reads a line from a file
B Gets file status
C Gets file size
D Gets file pointer position
Correct Answer:  A. Reads a line from a file
EXPLANATION

fgets() reads a string from a file until a newline character or end of file is encountered. It takes three arguments: buffer, size, and file pointer.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips