sscanf reading null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarwalsuchin
    New Member
    • Sep 2010
    • 1

    #1

    sscanf reading null

    I am reading a line and then using sscanf to split it into individual fields.

    But, somehow sscanf is reading the first character as null.

    I have four fields in my line separated by tabs. I need to check the presence of these 4 fields and also the 3 tabs separating the fields.

    Sample line: + 12345678 23.22 Initial

    My format string for sscanf is
    Code:
    sscanf(transstr,"%c%[\t]%ld%[\t]%lf%[\t]%s",&TransType,&tab1,&sectime,&tab,&amount,&tab,Description) != 7
    Help needed guys!!
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    + 12345678 23.22.

    Use scanf().

    First: scanf() for the +
    Second: scanf() for the integer
    Third: scanf() for the 23.22

    Verify these all work indivually.

    Then merge the three scanf() calls into a single
    sscanf().

    Comment

    Working...