第一周
- 学习了Git上传,注释、拉取等操作
- 利用SSH远程连接Linux系统进行代码已经程序运行编译
- 学习了企业部门里Github上传文件的格式,方便其他人查看编译等
- 学习使用Xmakelist 来对文件进行编译,生成MakeFile,已经CMakeLists文件
- 了解了文件的测试流程,以及将头文件的函数接口编译成动态库来进行调用测试等工作流程
- 规范了代码规范,其中包括命名规范,注释规范,代码缩进规范等
第一题 身份证的读取
用到的知识
ifstream 文件流
//1. 打开文件
ifstream inFile;
inFile.open(sFilePath, ios::in); //in 读 out 写 binary 二进制读等等
if(!inFile){
return -1;
}else{
cout << "success!" << endl;
}
查找文件的字节大小
fstream inFile;
inFile.open(m_sFilePath, ios::in);
inFile.seekg(0, ios::end); //指向末尾位 ios::end
m_nFileSize = (long)inFile.tellp(); //读取当前所指位置的pos
inFile.seekg(0, ios::beg); //归位 指向0 ios::beg
inFile.close();
- 所用函数
inFile.seekg(0, ios::end);
inFile.tellp();
lambda函数
auto GetMonthDay = [](int year, int month) {
int arrayDay[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))) {
return 29;
}
else {
return arrayDay[month];
}
};
字符串操作
auto comPare_1 = [](const string &s1, const string &s2){
return stoi(s1.substr(6, 8)) <= stoi(s2.substr(6, 8));
};
**s1.substr(6, 8) //截取字符串 从pos = 6 处 向后截取8个字符
stoi(s1.substr(6, 8)) //字符串转数字**