what is the difference between text and binary files. How do you decide when to use what?
For example, if you have to read pcm samples from an audio file that contains raw data, which mode would you open the file in?
what is the difference between text and binary files. How do you decide when to use what?
For example, if you have to read pcm samples from an audio file that contains raw data, which mode would you open the file in?
First of all, the difference between text and binary files doesn't exist, in the sense that you can open any file in text of binary mode if you choose. When you open a file in text mode in C or you use text stream operations in C++ then the operations take into account text features like e.g., line endings so you can ask things like readline().
For what you want to do though, you should use binary mode operations because you don't want these "interpret stream as text" features (they would produce incorrect results in your case anyway).