본문 바로가기

프로그래밍 _공부자료./C++ 공부46

문자열 은 똑같은데 하나의 숫자만 가변일때 해결법 c++ #include #include #include int main() { std::string logMessage = "데이터 오류 때문에 0 행이(가) 로드되지 않았습니다."; std::regex errorMessageRegex("데이터 오류 때문에 (\\d+) 행이\\(가\\) 로드되지 않았습니다."); // 오류 메시지에 매칭되는 정규 표현식 std::smatch match; if (std::regex_search(logMessage, match, errorMessageRegex)) { std::string numberString = match[1].str(); // 추출된 숫자를 문자열로 저장 int number = std::stoi(numberString); // 문자열을 정수로 변환 std::c.. 2023. 11. 1.
c++ 폴더를 생성하는 가장 간단한 방법 C++에서 폴더를 생성하는 가장 간단한 방법은 C++17부터 표준 라이브러리에 추가된 `` 라이브러리를 사용하는 것입니다. 이 라이브러리는 파일 시스템에 대한 여러 연산을 제공합니다. 아래 코드는 폴더가 없으면 생성하는 예제입니다: #include int main() { std::filesystem::path dir("path/to/directory"); if (!std::filesystem::exists(dir)) { std::filesystem::create_directories(dir); } return 0; } 위의 코드에서 `"path/to/directory"`는 실제로 생성하려는 디렉토리 경로로 바꿔주셔야 합니다. `std::filesystem::exists` 함수는 주어진 경로의 파일이나 디.. 2023. 10. 19.
c++ 특정폴더 하위 디렉토리 출력하는법 `std::filesystem::directory_iterator`를 사용하여 디렉토리의 직접적인 하위 항목만 나열하면 됩니다. 그런 다음, 각 항목이 디렉토리인지 확인하고, 디렉토리 이름을 출력합니다. #include #include void listSubdirectories(const std::string& directoryPath) { for (const auto & entry : std::filesystem::directory_iterator(directoryPath)) { if (entry.is_directory()) { std::cout 2023. 10. 19.
c++ 이중벡터 사용법및 데이터 패키징하는법 ```cpp #include #include #include #include int main() { std::ifstream inputFile("your_text_file.txt"); if (!inputFile.is_open()) { std::cerr 2023. 10. 18.