By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 1,007 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

sscanf reading null

P: 1
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
Expand|Select|Wrap|Line Numbers
  1. sscanf(transstr,"%c%[\t]%ld%[\t]%lf%[\t]%s",&TransType,&tab1,&sectime,&tab,&amount,&tab,Description) != 7
Help needed guys!!
Sep 10 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
+ 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
Sep 11 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.