Question
Download Solution PDFWhich of the following is the correct way to open a file "PRI.EXE" in read binary mode?
This question was previously asked in
Beltron Programmer 1 Oct 2023 Official Paper
Answer (Detailed Solution Below)
Option 2 : FILE *fp = fopen("PR1.EXE", "rb");
Free Tests
View all Free tests >
Beltron Programmer Mock Test
0.8 K Users
20 Questions
20 Marks
24 Mins
Detailed Solution
Download Solution PDFThe correct answer is Option 2) FILE *fp = fopen("PR1.EXE", "rb");.
Key Points
- The
fopen()
function in C is used to open files. - The second parameter specifies the mode in which the file should be opened.
"rb"
stands for read binary mode:- r: open for reading
- b: treat the file as binary, not text
- Therefore, the correct syntax to open a file named
PR1.EXE
in read-binary mode is:FILE *fp = fopen("PR1.EXE", "rb");
Additional Information
- Option 1 – Incorrect:
read-binary-mode
is not valid C syntax. - Option 3 – Incorrect:
O_READ | O_BINARY
is used inopen()
system call (low-level I/O), notfopen()
. - Option 4 – Incorrect:
READ | BINARY
is invalid and not part of standard C I/O mode strings. - Other common fopen modes:
"r"
: read (text)"w"
: write (text, truncates if exists)"a"
: append (text)"rb"
,"wb"
,"ab"
: binary equivalents
Last updated on Nov 25, 2024
-> BELTRON Programmer 2024 Notification has been released on the official website.
-> The Bihar State Electronics Development Corporation Limited (BELTRON) has announced a recruitment drive for Programmer positions on a contractual basis.
-> Specific vacancy details will be shared separately.
-> Interested candidates can apply online from November 11, 2024, to December 10, 2024.
-> The Minimum age of the candidates should be 21 years and maximum age should be 59 year of age.