2014年3月28日

不小心竟然自然自己写了个空指针

摘要: 在练习写程序过程中写下了如下一段代码。time_t time_t_time = time(NULL);tm *pTm = NULL;localtime_s(pTm, &time_t_time);自己最初的理解是将指针pTm初始化为空指针,然后localtime_s函数可以将time_t_time 的值赋给指针pTm在运行过程中提示 Exception ptm!=NULL。很显然localtime_s的操作是将time_t_time 的值存储的pTm的内存空间中,而不是让pTm重新指向time_t_time的内存地址。所以程序出错。 tm *pTm = new tm; localti.. 阅读全文

posted @ 2014-03-28 23:05 Leadtheway 阅读(338) 评论(0) 推荐(0)

string与time_t互相转换

摘要: #include #include #include using namespace std;time_t string2time_t(const string string_time);string time_t2string(const time_t time_t_time);int main(... 阅读全文

posted @ 2014-03-28 21:59 Leadtheway 阅读(7420) 评论(0) 推荐(0)

导航