c - HPUX atof doesn't convert string to double -
I am bringing the version number of an HPX machine and trying to convert it to float using Aot, but This happens: It prints: double return means That conversion failed The Utman Man page says that the strings have been aborted, so I do not understand why the ATF command is unsuccessful. Do I make any kind of mistake here? If you need it Add Focus on the top of your source file and compiler warnings. If you do not get any warning, then open your compiler in such a way that it warns about such a thing. Some backgrounds: Before the 1999 edition of ISO C standard, it was allowed to make a function call with no clear declaration. The compiler will assume that takes the argument of passed (propagated) types in the function call, and this returns the result of the result of New version of GCC (partially) support is the latest 2011 standard if you specify "-std = c11". See for details. #include & lt; Stdio.h & gt; # Include & lt; sys / utsname.h & gt; int main (int argc, char * argv []) {struct utsname u; Uname (& amp; u); Char * release = u.release; While (* Release! = '.') Release ++; Continue ++; printf ("% s \ n", release); Printf ("% f \ n", etf (release)); }
# ./test 11.31 0.000000
etf is function
& lt; Stdlib.h & gt; .
#include & lt; Stdlib.h & gt; Most likely the result is that (a) your compiler will print a warning (which you have clearly ignored), and (b) the compiler will assume that
etf returns a
int . / P>
#include & lt; Stdlib.h & gt;
(I do not know which compiler you are using, so I can not offer specifications.) For GCC, the compiler you are using, -wall
int This will usually work correctly if The function actually returns a
int , and if you type the call correctly (and if the functions are not different, like
printf ). The 1999 edition of the Standard Edition ("C99") left the "built-in
int " rule, with no clear declaration, any call violated an constraint , a diagnostic is required (which may be a non-fatal warning) Many compilers, warn only about the error and then handle the call under the old rules. And the GCC still does not apply the CML rules by default; Its default bid is "GNU 90", which includes the 1990 ISO-C standard plus GNU-specific extension. You can ask it to use C99 terms with "-std = c99"; Apply those words, you can use "-std = c99 -pedantic" or "-std = c99 -pedantic-errors".
Comments
Post a Comment