#include <iostream>
#include <string>
#include <direct.h>
#include <io.h>
#include <time.h>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
string& replace_all(string& str, const string& old_value, const string& new_value)
{
for(string::size_type pos(0); pos!=string::npos; pos+=new_value.length())
{
if( (pos=str.find(old_value,pos))!=string::npos )
str.replace(pos,old_value.length(),new_value);
else break ;
}
return str;
}
int main() {
string macAddress = "00:11:22:33:44:55";
macAddress = replace_all(macAddress,":","");
time_t currentTime = time(NULL);
char chCurrentTime[256];
strftime(chCurrentTime,sizeof(chCurrentTime),"%Y%m%d",localtime(¤tTime));
string stCurrentTime = chCurrentTime;
string path = stCurrentTime;
cout << path << endl;
if(0 != _access(path.c_str(),0))
{
int flag = _mkdir(path.c_str());
if (flag == 0) {
cout << "success" << endl;
} else {
cout << "fail" << endl;
}
}
char chCurrentTime1[256];
strftime(chCurrentTime1,sizeof(chCurrentTime),"%Y-%m %d %H:%M:%S",localtime(¤tTime));
string stCurrentTime1 = chCurrentTime1;
cout << _pgmptr << endl;
ofstream outfile;
outfile.open(".\\"+stCurrentTime+"\\"+macAddress,ios::app|ios::in|ios::out);
outfile << stCurrentTime1 << endl;
outfile << 1234 << endl;
outfile.close();
return 0;
}
07-24
1万+
06-28
1446