reading in a text file containing hex values

This is a discussion on reading in a text file containing hex values within the C Programming forums, part of the General Programming Boards category; Hmm, it seems you're right . . . one of the pages I linked to, the first one, does mention ...

  1. #31
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Hmm, it seems you're right . . . one of the pages I linked to, the first one, does mention it:

    http://www.cplusplus.com/reference/c...dio/fopen.html
    Additional characters may follow the sequence, although they should have no effect. For example, "t" is sometimes appended to make explicit the file is a text file.
    The others don't, however. I just looked over them quickly, saw mention of "b", and thought they'd mention "t". That was after looking at the first page, which did mention "t" . . . ah well. Me being lazy as usual.

    Another thing that may have confused me: the "t" flag does seem to be part of PHP.

    (I check all of those pages this time. Actually, they all contain the same text -- probably from a man page or something.)

    And the way my first reference talks about "t" does indeed make it sound like an extension. Digging a little deeper . . .

    http://velveeta.che.wisc.edu/octave/.../msg00419.html (Talking about Matlab)
    Also, we do not mention 'b' and 't' flags in the help text . . . I'm not thrilled to have a different default from the POSIX interface --- it will surprise C programmers.
    Seems to indicate that "t" is POSIX.

    http://www.decompile.com/cpp/faq/fopen_write_append.htm
    The Borland C++ Builder help page for fopen() says . . . To specify that a given file is being opened or created in text mode append a t to the mode string (rt w+t and so on).
    Seems to indicate that "t" exists, in Borland at least.

    http://msdn2.microsoft.com/en-us/lib...cb(VS.71).aspx
    The c, n, and t mode options are Microsoft extensions for fopen and _fdopen and should not be used where ANSI portability is desired.
    Definitely comes right out and says that "t" is not ANSI standard.

    http://www.cygwin.com/ml/cygwin/1998-01/msg00142.html
    First, since there is no "t" that can be passed to fopen(), it is impossible to tell if a call to fopen() wants a text mode open, or the default (blame POSIX/ANSI for that, I guess).
    Seems to vaguely indicate that "t" is ANSI/POSIX standard.

    http://www.mkssoftware.com/docs/man3/fopen.3.asp
    t, open in text mode . . . CONFORMANCE: ANSI/ISO 9899-1990, with exceptions.
    Is that one of the exceptions? Sigh.

    http://developer.apple.com/documenta...3/fopen.3.html
    The mode string can also include the letter ``b'' either as a third character or as a character between the characters in any of the two-charac-ter two-character strings described above. This is strictly for compatibility with ISO/IEC 9899:1990 (``ISO C90'') and has no effect; the ``b'' is ignored.
    Seems to say that "b" is ANSI; no mention of "t".

    I think it's safe to say that "t" isn't part of the ANSI standard, but whether it's POSIX or not is open to question. Either way, it's probably a good idea to avoid it -- though if it isn't standard, it's certainly quite widespread. I'm surprised it didn't make it into the C99 standard.

    Anyway. That's interesting. I nearly always use "rt" for ordinary reading. I'll have to start using just plain "r".
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #32
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I'm surprised it didn't make it into the C99 standard.
    Me too, actually. C99 added all kinds of goofy crap just to canonize bad or redundant practices, so why not a "t" mode to be symmetric with "b" mode?
    My best code is written with the delete key.

  3. #33
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Wow dwks, that's a lot of research for one letter.

    But yeah, it surprised me too when I found out that it wasn't standard. But it sort of makes sense since it's not really needed.
    Last edited by robwhit; 02-27-2008 at 11:44 AM.

  4. #34
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Quote Originally Posted by robwhit View Post
    Wow dwks, that's a lot of research for one letter.
    LOL. Yeah, I'm sure the search argument was "c t" and he just reviewed all the results.

    Todd
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  5. #35
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    LOL. Yeah, I'm sure the search argument was "c t" and he just reviewed all the results.
    People don't know how to google these days . . . googling for "c t" doesn't tell you anything. At least, unless you're interested in computed tomography or have a precious gem or need a cat scan or live in Connecticut . . .

    Wow dwks, that's a lot of research for one letter.
    Yes, well, I like to be thorough . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 05:27 PM
  2. disposing error
    By dropper166 in forum C# Programming
    Replies: 2
    Last Post: 03-31-2009, 12:53 AM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  4. reading from text file
    By jamez in forum C Programming
    Replies: 3
    Last Post: 11-30-2005, 07:13 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21