Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想我只是愚蠢(我尝试了所有)。帮我离开这里:
#include <stdio.h> #include <string.h> int main() { const char * y = "747.0"; double x; x = atof(y); printf("%.5f\n",x); printf("%e\n",x); return 0; }
结果:
0.00000 0.000000e+00
你需要包含stdlib.h提供atof()一个原型,如果没有合适的原型,编译器会假设它的返回值是一个int.
stdlib.h
atof()
int
尝试包含 stdlib.h,因为我认为这是 C 中 atoi 所需的包。