sscanf question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barry Schwarz

    #16
    Re: sscanf question

    On Sun, 3 Aug 2008 14:25:15 -0700 (PDT), vippstar@gmail. com wrote:
    >On Aug 3, 4:27 pm, CBFalconer <cbfalco...@yah oo.comwrote:
    >vipps...@gmail .com wrote:
    Chris Torek <nos...@torek.n etwrote:
    >>
    <snip>
    >>
    >(It is possible, but somewhat difficult, to "read a line" with
    >the scanf family. The code to do this is somewhat obscure. It
    >does appear here in comp.lang.c now and then.)
    >>
    I'd say it's impossible in robust code; the stream can have
    unwanted embedded null bytes, which scanf will happily read.
    >>
    >So? A null byte is not a digit, nor a period, so it will normally
    >be treated as marking the end of a numeric field.
    >
    >What are you talking about?
    Well, you said '\0' characters would pose some difficulty. He said
    they wouldn't.

    So let's start at the beginning. Why do you think they prevent robust
    code from using scanf? Before you answer, I suggest you look through
    the archives for posts by Dan Pop that describe exactly how to do
    this.

    --
    Remove del for email

    Comment

    • CBFalconer

      #17
      Re: sscanf question

      vippstar@gmail. com wrote:
      CBFalconer <cbfalco...@yah oo.comwrote:
      >vipps...@gmail .com wrote:
      >>Chris Torek <nos...@torek.n etwrote:
      >>
      >><snip>
      >>>
      >>>(It is possible, but somewhat difficult, to "read a line" with
      >>>the scanf family. The code to do this is somewhat obscure. It
      >>>does appear here in comp.lang.c now and then.)
      >>>
      >>I'd say it's impossible in robust code; the stream can have
      >>unwanted embedded null bytes, which scanf will happily read.
      >>
      >So? A null byte is not a digit, nor a period, so it will normally
      >be treated as marking the end of a numeric field.
      >
      What are you talking about?
      The handling of null (i.e. '\0') bytes by the scanf family.

      --
      [mail]: Chuck F (cbfalconer at maineline dot net)
      [page]: <http://cbfalconer.home .att.net>
      Try the download section.


      Comment

      Working...