Re: confused abt file operations



"siliconwafer" <spdandavate@xxxxxxxxx> wrote:
# Hi Again,
# So what about numbers wirtten to /read from the text/binary files?
# I read that in text files numbers are stored as characters or strings
# rather than their actual values.So a number 1234 will occoupy5 bytes(4
# + ' \0 ' ).In binary files,numbers are stored as actual values i.e 1234
# is stored as 2 bytes integer and so on..
# was the book correct?

You can write an arbitrary byte string to text or binary files, and you
can write ASCII (or EBCDIC or UTF16) strings to text or binary files.
Depending on your system, it might end convert some bytes in text mode.
There is nothing that will reach out and smack your C program, though
it might smack some of the bytes going out. It really is system specific.

If you stick to text mode with isprint() characters together with "\n"
and "\t", and don't assume fseek/ftell are byte offsets, you should
be compatiable with all other plain text processing programs on your
machine, and any other system with the same character set and character
encoding. There will also be character set convertors available.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Elvis was an artist. But that didn't stop him from joining the service
in time of war. That's why he is the king, and you're a shmuck.
.



Relevant Pages

  • Re: Unicode Support
    ... > Not knowing much about UTF-8 (my Unicode knowledge extends as far as ... > literal strings of this form as long as the character code for quote ... > can never appear in a MBCS (multibyte character sequence). ... then XP Notepad directly understands UNICODE and you can ...
    (alt.lang.asm)
  • Re: Need help on string manipulation
    ... better to convert strings to UCS-32 before manipulation? ... Characters represented by wchar_t must use one wchar_t per character, ... which may use a multibyte encoding. ... use some newer Unicode characters, if this is a problem for you, then ...
    (comp.lang.c)
  • Re: When will delphi have a unicode index operator ? ;)
    ... Will this code be wrong if the character set is a multi byte character ... shouldn't these character sets have there own type of strings with there own ...
    (alt.comp.lang.borland-delphi)
  • Re: Copying string to byte array
    ... of Strings and the CryptEncrypt + CryptDecrypt APIs. ... binary data should not be held in String variables. ... a) not all character codes are valid in a given ...
    (microsoft.public.vb.general.discussion)
  • Re: Zero terminated strings
    ... standard library that told you how to encode strings.) ... this redundant terminator as well). ... (Other string libraries like Vstr have ...
    (comp.lang.c)