你应该好好看一下msdngmtime, mktime, and localtime all use a single statically allocated tm structure for the conversion. Each call to one of these routines destroys the result of the previous call.

解决方案 »

  1.   

    gmtime, mktime, and localtime all use a single statically allocated tm structure for the conversion
    的意思是tm是静态局部变量吗?
      

  2.   

    time_t current_time;  // 分配在栈中
    time_t *current_time = new time_t; // 在分配堆中, use delete to free the resource
      

  3.   

    可是我看了源代码,不是这样的,是reg型的
      

  4.   

    struct tm *datetime; 是说明datetime是一个指向struct tm的指针了,后面的&datatime的意思是指向指针的指针,一个例子可以说明,象COM中的接口的QueryInterface函数就是需要传递指向指针的指针作为参数。
    在同一作用域中new 要和 free 匹配。这就象{}一样啊。关于内存管理你应该好好看看MSDN,这和Windows操作系统有关。
      

  5.   

    这个结构体指针没有给它初始化内存空间,好像不能free掉吧