#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;
}
c++ mac替换冒号以及文件写入
最新推荐文章于 2023-05-31 11:22:09 发布
本文介绍了一个使用C++进行文件操作的例子,包括创建目录、写入文件等,并展示了如何处理MAC地址字符串及获取当前时间。此外,还演示了字符串替换的方法。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
ACE-Step
音乐合成
ACE-Step
ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言
3348

被折叠的 条评论
为什么被折叠?



