C Programming Questions and Answers – File Access – 1

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “File Access – 1”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

advertisement

1. What are the first and second arguments of fopen?
a) A character string containing the name of the file & the second argument is the mode
b) A character string containing the name of the user & the second argument is the mode
c) A character string containing file pointer & the second argument is the mode
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

2. For binary files, a ___ must be appended to the mode string.
a) Nothing
b) “b”
c) “binary”
d) “01”
View Answer

Answer: b
Explanation: None.
advertisement
advertisement

3. What will fopen will return, if there is any error while opening a file?
a) Nothing
b) EOF
c) NULL
d) Depends on compiler
View Answer

Answer: c
Explanation: None.

4. What is the return value of getc()?
a) The next character from the stream is not referred by file pointer
b) EOF for end of file or error
c) Nothing
d) None of the mentioned
View Answer

Answer: b
Explanation: None.
advertisement

5. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?
a) Standard input
b) Standard output
c) Standard error
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

6. In C language, FILE is of which data type?
a) int
b) char *
c) struct
d) None of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement

7. What is meant by ‘a’ in the following C operation?

fp = fopen("Random.txt", "a");

a) Attach
b) Append
c) Apprehend
d) Add
View Answer

Answer: b
Explanation: None.
advertisement

8. Which of the following mode argument is used to truncate?
a) a
b) f
c) w
d) t
View Answer

Answer: c
Explanation: None.

9. Which type of files can’t be opened using fopen()?
a) .txt
b) .bin
c) .c
d) none of the mentioned
View Answer

Answer: d
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter

Check his free tutorial videos on Advanced C Programming. Join his Sanfoundry-Classes telegram channel for all videos and queries on Programming, Data-Structures, Kernel, Personality development and Mentoring.