I have used this several times in the past for writing to files. Is there a problem with this? I'm just writing text. I have never had any issues. What is the difference with the binary file? I thought binary files usually weren't readable. I read those two links and they don't really explain it.

FILE *init_dat_fp;

init_dat_fp = fopen (argv[1], "wb");

http://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm
http://www.cplusplus.com/reference/cstdio/fopen/

The binary mode is a legacy feature for a time when some computers had different memory encoding for binary versus text data. This distinction hasn't been relevant on any platform for a long time (probably 20-30 years), as far as I know. I guess you can still apply the "b" flag whenever you're opening a binary file (or intend to write binary data to a file), just to be pedantic, but it makes no difference in practice.

There are times when this does matter. If I recall correctly Windows will translate \n to \r\n automagically unless you specify binary mode. I can't remember the exact order of events to tickle this situation but if you expect to produce accurate cross-platform content binary mode is one step you want to take.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.