随笔分类 -  C++ / C++实战案例

C++ 实战,标准类的用法
摘要:// Source : https://www.geeksforgeeks.org/bitonic-sort/ /* C++ Program for Bitonic Sort. Note that this program works only when size of input is a pow 阅读全文
posted @ 2024-12-09 16:36 经纬视界 阅读(50) 评论(0) 推荐(0)
摘要:/// c++ 内存文件使用例程class MemoryBuffer : public std::strstreambuf { public: using Base = std::basic_streambuf<char>; using char_type = typename Base::char 阅读全文
posted @ 2023-12-25 09:49 经纬视界 阅读(53) 评论(0) 推荐(0)
摘要:#include <iostream> #include <filesystem> #include <string> namespace fs = std::filesystem; void demo_status(const fs::path& p, fs::file_status s) { s 阅读全文
posted @ 2023-12-04 13:31 经纬视界 阅读(80) 评论(0) 推荐(0)
摘要:1.path类:文件路径相关操作,如指定的路径是否存在等; 2.directory_entry类:获取文件属性等,如指定文件是否是常规文件,还包括文件大小、文件最后修改时间; 3.directory_iterator类:遍历目录,获取目录文件,不包括子目录,其介绍参见; 4.recursive_di 阅读全文
posted @ 2023-12-04 13:25 经纬视界 阅读(50) 评论(0) 推荐(0)
摘要:#include <iostream> #include <fstream> using namespace std; int main() { ifstream infile; try { infile.open("file.txt"); if (!infile) { throw runtime_ 阅读全文
posted @ 2023-12-04 13:21 经纬视界 阅读(46) 评论(0) 推荐(0)
摘要:#include <iostream> #include <semaphore> #include <thread> using namespace std; std::counting_semaphore<3> csem(0); // semaphore release = condition_v 阅读全文
posted @ 2023-12-01 09:03 经纬视界 阅读(75) 评论(0) 推荐(0)
摘要:#include <iostream> #include <filesystem> namespace fs = std::filesystem; void traverseDirectory(const std::string& path) { for (const auto& entry : f 阅读全文
posted @ 2023-11-30 16:32 经纬视界 阅读(1061) 评论(0) 推荐(0)
摘要:#include <iostream> #include <strstream> using namespace std; int main() { char szBuf[16] = {"hello world!"}; std::strstreambuf memo(szBuf,sizeof(szBu 阅读全文
posted @ 2023-11-30 10:51 经纬视界 阅读(77) 评论(0) 推荐(0)