ExamVeda
Login
Home
1
In C, which library is used for file operations such as reading and writing files?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
2
Which function is used to open a file in C for writing?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
3
What does 'FILE' represent in C when working with files?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
4
How do you check if a file was opened successfully in C?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
5
Which function is used to write data to a file in C?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
6
What is the difference between 'r' and 'w' modes when opening a file in C?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
7
How do you read a character from a file in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
The correct answer is A: getc()
Let's break down why:
getc() is a standard C library function specifically designed to read a single character from a file stream.
It takes a file pointer (FILE*) as an argument and returns the character read (as an integer) or EOF if the end of the file is reached or an error occurs.
readchar() is not a standard C function for file input.
read() is a lower-level function (usually from the POSIX standard) used for reading a block of data from a file descriptor, not a single character.
getchar() reads a character from standard input (stdin), which is usually the keyboard, not from a file.
So, getc() is the correct function to use when you want to read a single character from a file in C.
8
What is the purpose of the 'fprintf' function in C?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
9
Which function is used to close a file in C?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
10
In C, what is the function of the 'feof' function?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board