On Sunday 04 May 2008 03:19:29 David C. Rankin wrote:
Listmates,
I was comparing input handling between perl and c and I ran into a very weird problem with the strtof function in c. What am I doing wrong? strtof doesn't seem to be working like the man page shows. Here is my test bit of code: [...] The code compiles without error or warning with: "gcc -o prg/tmp src/tmp.c" Here is the bewildering output:
Well, no it doesn't. It says "implicit declaration of stdtof" If you read the man page for strtof it says Feature Test Macro Requirements for glibc (see feature_test_macros(7)): strtof(), strtold(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99 So try gcc -std=c99 -o prg/tmp src/tmp.c Without that -std=c99, gcc simply doesn't know what strtof() is, and calls it incorrectly (it assumes it accepts an int as parameter and returns an integer, and generates assembly accordingly. You're unlucky you got bad data - the 'good' return value would have been a seg fault) Anders -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org