char datebuf[18];
   CString str1;
    time_t ltime;
   struct tm *today;        today = localtime(&ltime);    strftime(datebuf,18,"day:%dmon:%Byear:%Y",today);//执行到这里出错
    str1=(CString)datebuf;
    AfxMessageBox(str1);

解决方案 »

  1.   

    today没有值
    在today = localtime(&ltime);前

    time(&ltime);
      

  2.   

    char datebuf[18];
       CString str1;
       time_t ltime;
       struct tm *today;       time(&ltime);
        today = localtime(&ltime);    strftime(datebuf,18,"day:%dmon:%myear:%Y",today);//执行到这里出错
        str1.Format("%s", datebuf);
        AfxMessageBox(str1);
      

  3.   

    改成:time(&ltime);                  // 获得当前时间。
    today = localtime(&ltime);
      

  4.   

    char datebuf[100]; // 18 is NOT enough