我这里有一个使用localtime函数的代码.但是对于其输入参数的某些值,代码崩溃(返回空指针).我想知道它的输入允许范围.
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm g;
struct tm *gp;
__int64 tim;
tim = 7476811632013133299LL; // I know it's a weird number but valid for time_t
rawtime = tim / 1000LL;
gp = localtime(&rawtime);
printf("Pointer gp = %p\n", gp);
g = *gp; // this crahses because gp = NULL
return 0;
}
Run Code Online (Sandbox Code Playgroud)
那么可以说关于本地时间函数的允许输入范围呢?