我有这个代码将ASCII字符串转换为int,float或double.但是,它为所有这些打印"42".我哪里做错了?语法看起来正确,没有警告.
#include <stdlib.h>
int main(void)
{
char *buf1 = "42";
char buf2[] = "69.00";
int i;
double d;
long l;
i = atoi(buf1);
l = atol(buf1);
d = atof(buf2);
printf("%d\t%d\t%d\n", i, l, d);
return 0;
}
Run Code Online (Sandbox Code Playgroud) c ×1