C Programming - Input / Output - Discussion
Discussion Forum : Input / Output - Yes / No Questions (Q.No. 2)
2.
A file written in text mode can be read back correctly in binary mode.
Answer: Option
Explanation:
If you write a file in text mode and then read it back in binary mode, the translations performed in text mode may result in the file's contents being misinterpreted or incorrectly read in binary mode. For consistent behavior, a file should be read and written in the same mode (both text or both binary).
Discussion:
2 comments Page 1 of 1.
MrMino said:
10 years ago
The file written as text can be read with fread (& some_char, sizeof (char), 1, input); in loop. It will spew out eols anyway. As long as text is encoded in ASCII.
Jim Dines said:
8 years ago
The answer to this question is yes. You can read the file back just fine. When you do it will have the appropriate CR/LF or LF at the end of each line that was written/appended when opened in text mode.
I also agree @Mrmino.
I also agree @Mrmino.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers