Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Re: Having diff...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 3785 of 3840
Post > Topic >>

Re: Having difficulty with sscanf on my Mac

by William Woody <woody@[EMAIL PROTECTED] > Jun 27, 2008 at 07:16 PM

In article 
<ae12db6f-80d8-4cf1-a1c4-282f989c8490@[EMAIL PROTECTED]
>,
 Robert <Ritterhaus@[EMAIL PROTECTED]
> wrote:

> I can't seem to get sscanf to work for some odd reason on my Macbook
> Pro. The following code:
> 
> sscanf(string, "%f", &double_var);
> 
> Doesn't do as expected. According to gdb, double_var goes from 0.0
> (where I initialized it) to 5.14...e-315 (a number so small, it is
> essentially zero.) Even if I use a string literal:
> 
> sscanf("123.456789", "%f", &double_var);
> 
> I get similar results---a tiny number that is basically equivalent to
> zero. Any thoughts? Anyone else run into this?


From

http://www.cplusplus.com/reference/clibrary/cstdio/sscanf.html

The format specifier %f will scan for a float, not a double. (I'm 
assuming the double_var is declared double.) If you're reading a double 
var, you need to give the format specifier %lf

Hope this helps.

-- 
William Edward Woody   -   woody@[EMAIL PROTECTED]
 In Motion        -   http://www.chaosinmotion.com

Freedom is the non-negotiable demand of human dignity; 
the birthright of every person‹-in every civilization.
            - National Security Strategy of the United States
 




 2 Posts in Topic:
Having difficulty with sscanf on my Mac
Robert <Ritterhaus@[EM  2008-06-27 19:02:59 
Re: Having difficulty with sscanf on my Mac
William Woody <woody@[  2008-06-27 19:16:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 0:29:29 CDT 2008.