【CPP】文件后缀校验

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>

int main()
{
std::string fn = "filename.conf";
if(fn.substr(fn.find_last_of(".") + 1) == "conf") {
std::cout << "Yes..." << std::endl;
} else {
std::cout << "No..." << std::endl;
}
}

【CPP】文件后缀校验
https://hodlyounger.github.io/B_Code/CPP/【CPP】文件后缀校验/
作者
mingming
发布于
2023年10月27日
许可协议