Re: Binary or Ascii Text?



Claude Yih wrote:
Hi, everyone. I got a question. How can I identify whether a file is a
binary file or an ascii text file? For instance, I wrote a piece of
code and saved as "Test.c". I knew it was an ascii text file. Then
after compilation, I got a "Test" file and it was a binary executable
file. The problem is, I know the type of those two files in my mind
because I executed the process of compilation, but how can I make the
computer know the type of a given file by writing code in C? Files are
all save as 0's and 1's. What's the difference?

Please help me, thanks.

As others have said, this is an essentially arbitrary decision on your part. Here we've standardized on a definition of "binary" that means:

Lines greater than X bytes (where "X" is some arbitrarily high number, like 16 or 23k), or any character within the file is \0 or null.

I line is defined as data between newlines (normalized to '\n').

Everything else fits into a reasonable notion of OEM or ANSI charset, with some caveats.

Again, this is specific to application requirements. Your requirements may vary.
.



Relevant Pages

  • Re: Binary or Ascii Text?
    ... Claude Yih wrote: ... I knew it was an ascii text file. ... after compilation, I got a "Test" file and it was a binary executable ... computer know the type of a given file by writing code in C? ...
    (comp.lang.c)
  • Re: <ctype.h> toLower()
    ... the /output/ of the compilation is object code, ... >> Then find a newsgroup where such discussion is topical. ... >> restrict ourselves to ASCII. ... because EBCDIC is what IBM mainframe hardware uses, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Binary or Ascii Text?
    ... I knew it was an ascii text file. ... after compilation, I got a "Test" file and it was a binary executable ... computer know the type of a given file by writing code in C? ... It removes the CR from the CRLF pair and ignores any trailing ^Z character. ...
    (comp.lang.c)
  • Re: Binary or Ascii Text?
    ... I knew it was an ascii text file. ... # after compilation, I got a "Test" file and it was a binary executable ... As far as stdio is concerned, a binary file is what you get if you ... include a "b" in the open mode, ...
    (comp.lang.c)
  • Re: Burning ROM
    ... You mean I should choose DVD Copy compilation? ... There isn't any preferences in this compilation like choosing file system, ... I choose ASCII and ISO 9660:1999 becouse to get the proper lenght of the ...
    (microsoft.public.windowsxp.video)