How do you know that it is reading only 5? Are you using a debugger or using printf? If you are using printf maybe you are using a wrong format specifier.

Because if I don't use that method and just print out some number it works.

I've used the following specifiers:

%f -- gives 5.000000

%.2g gives 5 ( g is the only one I know how to use to format decimal places)


Uhhh, why does C have to be a pain in the butthole?

It's reading the 5.5, but for some reason it's being truncated in the conversion:

int num;
        if (sscanf(text,"%d",&num) == 1 && num > 0)

It's reading the 5.5, but for some reason it's being truncated in the conversion:

int num;
        if (sscanf(text,"%d",&num) == 1 && num > 0)

But %d is the format specifier to read an integer. So it will read only the integer part of the contents in text . You have to use something like %f or %lf . I dont know what is standard specific ( I thought lf was the correct one for double, but someone said above that it was wrong, but my MSVC compiler only reads double for the %lf specifier) . I also saw some suggestions for a double in the above replies of this thread. you can lookup them.

Note:
English is not my first language. I dont know if being suggested to be a masochist is offending so much. But I know that being called an asshole is. I think that type of language is uncalled for. Think twice before posting things like that.

But %d is the format specifier to read an integer. So it will read only the integer part of the contents in text . You have to use something like %f or %lf . I dont know what is standard specific ( I thought lf was the correct one for double, but someone said above that it was wrong, but my MSVC compiler only reads double for the %lf specifier) . I also saw some suggestions for a double in the above replies of this thread. you can lookup them.

Wow, that makes me feel dumb. For some reason I was thinking %d for for double. Although, I believe I have tried %f with double and it gave weird results.

Note:
English is not my first language. I dont know if being suggested to be a masochist is offending so much. But I know that being called an asshole is. I think that type of language is uncalled for. Think twice before posting things like that.

Why don't you head on over to dictionary.com and tell me which is worse, what he said, or what I said. I'm still fuming over that. I could have said a lot more but I had some self control.

Think twice before posting things like that.

Oh, believe me, I did. I thought it through really well. I could have filled up a whole page on what I really wanted to say to that....

This seemed to work for me:

float num;
        if (sscanf(text,"%f",&num) == 1 && num > 0)
Member Avatar for iamthwee

Oh, believe me, I did. I thought it through really well. I could have filled up a whole page on what I really wanted to say to that....

A- ha ha ha. What you say is pure gold server_crash. I'm adding to your rep.
btw, what are the specific reasons why you need to use miracle c dude?

A- ha ha ha. What you say is pure gold server_crash. I'm adding to your rep.

Hey, ya know, what's wrong with a little excitement? I knew YOU would understand:cheesy:

btw, what are the specific reasons why you need to use miracle c dude?

Personal reasons. I was testing something stupid, but I just dropped it. I like Dev C++ too much.

commented: gold +1

Why don't you head on over to dictionary.com and tell me which is worse, what he said, or what I said. I'm still fuming over that. I could have said a lot more but I had some self control.

Okay. I did. I found what Salem would have meant.

# A willingness or tendency to subject oneself to unpleasant or trying experiences.

This was what I thought Salem meant when I saw his reply at first. Is this so much agitating to you?
Edit:

Hey, ya know, what's wrong with a little excitement? I knew YOU would understand

Okay. All is cool. I consider the original intent of this thread achieved.

Member Avatar for iamthwee

Okay. I did. I found what Salem would have meant.
This was what I thought Salem meant when I saw his reply at first. Is this so much agitating to you?
Edit:
Okay. All is cool. I consider the original intent of this thread achieved.

All that mod power has gone to your head wolfie. ;)

This was what I thought Salem meant when I saw his reply at first. Is this so much agitating to you?

I think you missed part/most of the defintion:

The deriving of sexual gratification, or the tendency to derive sexual gratification, from being physically or emotionally abused.

I'll just settle this in a PM with this dirt bag.

All that mod power has gone to your head wolfie. ;)

ehehee. Well it is your fault that I am a moderator(you know what I am speaking about ;) ) Anyway I realized this would come up. Well what can I say.... I wouldnt have said a thing if server_crash called you an [Profanity edited for the G-rated among us....] :p I would just sat back and enjoyed it. he he he. But I think Salem does not deserve to be called that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.