0

I have the following problem I'm trying to print the return of this function and I'm having a segmentation fault and idk why

  char * cfnGetTime()
{
    char * szDate;
    struct tm *ptTime;
    time_t tTimeNow;
    
    /* Get date and time */
    (void)time(&tTimeNow);
    ptTime=localtime(&tTimeNow);
    (void)strftime(szDate, MAXPATHLEN, "%Y%m%d%H%M%S", ptTime);
    
    return szDate;
} 

when I do this

fprintf(gpfdLogFile, "%s%s - Comienza el proceso %s version %s\n", 
            __LINE__, cfnGetTime(), MODULO, LABEL);

0 Answers0