我的想法是,如果用户输入t = 2.5
,那么我在 2 个不同的变量中分别提取 2 和 0.5 。但我无法做到这一点。
这是代码:
$ export LT_LEAK_START=1.5
$ echo $LT_LEAK_START
1.5
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
double d;
time_t t;
long nsec;
d=strtod(getenv("LT_LEAK_START"), NULL);
t=(time_t)d;
nsec=d-(double)((time_t)d); // Extract fractional part as time_t always whole no.
printf("d = %lf\n",d);
printf("t = %u, nsec = %f\n",d,nsec);
}
输出是:
# ./a.out
d = 1.500000
t = 0, nsec = 0.000000