报错求助

specter1210 specter1210 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
引用
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <string>
using namespace std;


string& TiHuan(string& str,const string& old_date,const string& new_date)
{
for(string::size_type pos(0);pos!=string::npos;pos+=new_date.length())
{
if( (pos=str.find(old_date,pos))!=string::npos )
{
str.replace(pos,old_date.length(),new_date);
}
else
break;
};
return str;
};

int main(void)
{


//Son.ShowTheData(10);
//char i_date[1096]={0};
char *i_date=NULL;
//char DateBuffer[50]={0};
char Month[20]={0};
time_t TheDate;
time(&TheDate);
printf("time is: %s", ctime(&TheDate));
memcpy(i_date,ctime(&TheDate) + 4,20);
//memcpy(Month,ctime(&TheDate) + 4,3);
string Date = "12345";
Date = i_date;

TiHuan(Date,"Jan","01");
TiHuan(Date,"Feb","02");
TiHuan(Date,"Mar","03");
TiHuan(Date,"Apr","04");
TiHuan(Date,"May","05");
TiHuan(Date,"Jun","06");
TiHuan(Date,"Jul","07");
TiHuan(Date,"Aug","08");
TiHuan(Date,"Sep","09");
TiHuan(Date,"Oct","10");
TiHuan(Date,"Nov","11");
TiHuan(Date,"Dec","12");
const char *DateBuffer = Date.c_str();
cout<<"date is:"<<Date<<endl;
//memcpy(DateBuffer,i_date,20);
if(strncmp(DateBuffer,"09 05 14:35:03 2016",20) > 0) //Mon Dec 05 14:35:03 2016
{
cout<<"time is over"<<endl;
}
else
{
cout<<"u can use it"<<endl;
};

system("pause");

return 0;
};



报错
0x0ff9caa8 (msvcr100d.dll) 处最可能的异常: 0xC0000005: 写入位置 0x00000000 时发生访问冲突
0x101acaa8 (msvcr100d.dll) 处有未经处理的异常: 0xC0000005: 写入位置 0x00000000 时发生访问冲突

麻烦大神帮忙看看
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
specter1210
C++ 语言 65,214 成员 250,514 内容