Can some one please give me a simple example of "atof" function use.
I want to convert a string like this char s="11.1994"; to a float.
Your help is appreciated
f = atof(s);
f = atof(s);
Thanks for your input. I am going to try it.
I gotta ask - doesn't your C compiler have a manual? Did it not show an example of how to use it? How about your copy of K&R?
Maybe he just doesn't own any of these books or manuals, but what really puzzles me is the fact that he's able to ask in a forum but unable to google for the info...
I fear these are just the signs of the times: instant satisfaction is what they are after, be it free advice for exactly their problem, or an instant meal at the drive-in of their favourite burger shop without even leaving the car (i was about to write "move their ass", but i guess this would be politically incorrect). But avoid like hell any effort...
Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."
True enough. My favourite C reference these days is now:
I almost never open a C manual any more because of that site.
The fact it is such a good/popular resource for C programmers is reflected in the fact that this is the very top hit if you Google only for the four letters "atof" !
Could we include this picture at the very top of the avrfreaks web pages?
I read in the http://www.cplusplus.com/referen... ... dlib/atof/ , I went to AVR C library and look into it, also, I look in a Portuguese C book. All I read was like the example gave to me, and I was doing the code as the example as well as the books, but, I was getting always a compiler error without mention the error type.
I asked just to make sure I was doing it the right way. I already solved the problem and was not related with the "atof", it was due to a wrong variable assignment type.
Clawson, your help was appreciated.
Thanks any way.
I was getting always a compiler error
I bet I know what this is... just gazing into my crystal ball .... the smoke is clearing ... I see avr-gcc ... I see AVR Studio ... oh, wait a minute, I DON'T see libm.a ... oh dear.
It's very unwise to call any kind of floating point function in avr-gcc if your linker invocation does not include "-lm", which forces libm.a to be linked. Both AS4 and AS5 do not do this by default.
Of course this could be a completely different compiler or a completely different environment - my crystal ball has been on the fritz ever since one of the kittens knocked it off its stand!
© 2022 Microchip Technology Inc.