这里有什么问题?不要紧,我选择什么号码海峡,它始终是26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00为什么strtof总是评估为HUGE_VAL?
char *str = "2.6";
printf("%f\n", strtof(str, (char**)NULL));
//prints 26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00
整个程序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *str = "2.6";
printf("%f\n", strtof(str, NULL));
return 1;
}
与-Wall编译:
test4.c:7: warning: implicit declaration of function âstrtofâ
它在这里工作正常;你在用一种不寻常的方式建设吗? – 2010-06-02 17:33:12
gcc -o test4 test4.c – user318747 2010-06-02 17:34:17
尝试'gcc -Wall' – 2010-06-02 17:36:10