atof() for float instead of double

Elmi picture Elmi · Dec 7, 2016 · Viewed 6.9k times · Source

atof() returns a double, which results in a warning when I assign it to a float-value (and yes, I definitively have to use float).

So my question: is there a atof()-variant available which returns a plain float? Or do I have to solve this by a cast - which would be a pity because it wastes resources for creating a double which will be thrown away immediately.

Answer

Henningsson picture Henningsson · Dec 7, 2016

Use strtof instead, it will return a float.

See documentation here