본문 바로가기

개발/C++4

Convert IPv4 To IPv6 #include #include #ifdef _WIN32 #include #include #pragma comment(lib, "Ws2_32.lib")#else #include #include #endifbool convertIPv4ToIPv6(const std::string& ipv4AddrStr, std::string& ipv6AddrStr) { struct in_addr ipv4Addr; struct in6_addr ipv6Addr; // Convert the string IPv4 address to in_addr if (inet_pton(AF_INET, ipv4AddrStr.c_str(), &ipv4Addr) != 1) { std:.. 2024. 5. 21.
[ C++] StringUtil Class #pragma once #include class cStringUtil { public: static std::wstring MBSToWCS( const std::string& _ssMbsStr, UINT _nCodePage = CP_UTF8 ); // 유니코드 문자열을 멀티바이트 문자열로 변환 static std::string WCSToMBS( const std::wstring& _ssWcs, UINT _nCodePage = CP_UTF8 ); // Format 함수는 가변 인수를 받아 들여 std::wstring을 포맷합니다. template static std::wstring Format( const std::wstring& format, Args&&... args ) { return std::vf.. 2024. 4. 22.
[C++] StringFormat 만들기 C++20 이상: std::format 사용 예시 C++20에서는 std::format이라는 새로운 함수를 도입하여 문자열 포맷팅을 더욱 쉽게 할 수 있게 되었습니다. 이 함수는 Python의 str.format과 유사한 방식으로 작동합니다. 다만, std::format은 컴파일 시간에 포맷 문자열을 검사하여 타입 안전성을 보장합니다. #include #include #include template std::string stringformat(const std::string& format, Args ... args) { size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; if (size 2024. 3. 4.
[C++] 절대 경로 비교 아스트릭 처리된 경로 비교를 해봅시다 절대 경로를 비교 할 때 * 처리된 경로까지 넣어서 비교해 봅시다.\ 구현 /****************************************************************************** * _ _ _ _ __ _____ _ _ *| | | | | | | |/ / | __ \ | | | | *| |__| | __ _ ___ | |_ _| ' / | | | | _____ __ | | __ _| |__ *| __ |/ _` |/ _ \_ | | | | | < | | | |/ _ \ \ / / | | / _` | '_ \ *| | | | (_| | __/ |__| | |_| | . \ | |__| | __/\ V / | |___| (_| | .. 2024. 2. 14.
반응형