# Binary file

**URL:** <https://community.unix.com/t/binary-file/240652>\
**Category:** Programming\
**Created:** [May 21, 2009, 6:03am UTC](https://community.unix.com/t/binary-file/240652 "2009-05-21T06:03:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshighanshyam](https://community.unix.com/letter_avatar/joshighanshyam/32/6_449c533f586939b6e5f246632a46421f.png) [@joshighanshyam](https://community.unix.com/u/joshighanshyam)\
**Post date:** [May 21, 2009, 6:03am UTC](https://community.unix.com/t/binary-file/240652/1 "2009-05-21T06:03:53Z")

</div>

Hi all  
I have a C program to write it's output into a textfile which is also created by the program in between. The file that's get created prompt's a message while opening manually that the file is binary and any change in that leads to it's corruption.

I have used putc() to write the output to file.  
I have also detected if i simply used the fopen() with file name (option "b" is not used) and then simply closed it using fclose() then a plaintext file get created which does not display above message.

The program is giving plain text file in windows which is expected.  
How can i avoid the creation of binary file..?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [May 21, 2009, 10:53am UTC](https://community.unix.com/t/binary-file/240652/2 "2009-05-21T10:53:13Z")

</div>

What is the output from this command - assumes your file is called myfile.txt

```nohighlight
/usr/bin/file myfile.txt

```

You may be writing non-ascii "junk" characters to your file.

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [May 22, 2009, 12:23pm UTC](https://community.unix.com/t/binary-file/240652/3 "2009-05-22T12:23:59Z")

</div>

If you do not want to create a binary file, then do not open or create using binary mode flag.
