随笔分类 -  c++

工作笔记
摘要:#include <iostream> #include <map> int main() { std::map<int, int> myMap = { {1, 100}, {2, 200}, {3, 300} }; void* ptr = &myMap; // 安全转换 + 检查 if (!ptr 阅读全文
posted @ 2025-05-26 11:17 leochan007 阅读(14) 评论(0) 推荐(0)
摘要:#include <iostream> #include <chrono> #include <ctime> #include <iomanip> #include <sstream> int main() { // 获取当前时间点 auto now = std::chrono::system_cl 阅读全文
posted @ 2025-01-23 16:36 leochan007 阅读(25) 评论(0) 推荐(0)
摘要:#define STRINGIFY(x) #x int someVariable = 10; std::cout << STRINGIFY(someVariable) << " = " << someVariable << std::endl; 阅读全文
posted @ 2024-12-27 11:37 leochan007 阅读(11) 评论(0) 推荐(0)
摘要:#include <iostream> #include <sstream> #include <iomanip> #include <ctime> bool compareTimeStrings(const std::string& timeStr1, const std::string& tim 阅读全文
posted @ 2024-12-24 15:47 leochan007 阅读(31) 评论(0) 推荐(0)
摘要:#include <stdio.h> void print_binary(unsigned int n) { for (int i = sizeof(n) * 8 - 1; i >= 0; i--) { printf("%d", (n >> i) & 1); } printf("\n"); } vo 阅读全文
posted @ 2024-12-12 17:51 leochan007 阅读(14) 评论(0) 推荐(0)
摘要:#include <iostream> #include <fstream> int main() { std::ifstream sourceFile("source.txt", std::ios::binary); // 打开源文件 if (!sourceFile) { std::cout << 阅读全文
posted @ 2024-01-03 12:31 leochan007 阅读(19) 评论(0) 推荐(0)
摘要:新手VSCode配置C++20 Makefile教程1 快速入门 HTTP 代理服务器的设计与实现(C++) 阅读全文
posted @ 2023-12-05 11:49 leochan007 阅读(16) 评论(0) 推荐(0)
摘要:// testfindfile.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include <windows.h> bool SearchFilesByWildcard(const WCHAR* wildcardPath) 阅读全文
posted @ 2023-11-02 16:43 leochan007 阅读(79) 评论(0) 推荐(0)
摘要:// testmutex.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include "windows.h" HANDLE m_hMutex; #include<list> using namespace std; lis 阅读全文
posted @ 2023-05-24 15:34 leochan007 阅读(17) 评论(0) 推荐(0)
摘要:C++中将string类型转换为double的方法:#include <iostream>#include <sstream> //使用stringstream需要引入这个头文件using namespace std;//模板函数:将string类型变量转换为常用的数值类型(此方法具有普遍适用性)t 阅读全文
posted @ 2023-02-08 14:51 leochan007 阅读(70) 评论(0) 推荐(0)
摘要://Log.h #ifndef LOG_HEAD_DEF #define LOG_HEAD_DEF #pragma once #include "stdio.h" #include <stdarg.h> ////用变参函数所必须的 #include <time.h> #include <direct 阅读全文
posted @ 2022-12-03 21:19 leochan007
摘要:#include <iostream> #define new_fun(parm) print##parm("this is a printf\r\n"); int main() { //new_fun(oh); //无法编译通过 new_fun(f); getchar(); return 0; } 阅读全文
posted @ 2022-10-26 17:32 leochan007 阅读(52) 评论(0) 推荐(0)
摘要://Minidump.h #pragma once class CMinidump { public: CMinidump(); ~CMinidump(); static void CreateDumpFile(LPCSTR lpstrDumpFilePathName, EXCEPTION_POIN 阅读全文
posted @ 2022-10-23 14:38 leochan007
摘要:#include <iostream> void getfilename(const char* filename, char* name)//从完整路径名中解析出文件名称,例如:/home/test/abc.txt,解析完成后为abc.txt { int len = strlen(filename 阅读全文
posted @ 2022-07-27 16:48 leochan007 阅读(381) 评论(0) 推荐(0)
摘要:#include <iostream> #include<direct.h> #include<io.h> bool CheckPathExist(std::string path) { if (access(path.c_str(), 0) == -1) { return false; } ret 阅读全文
posted @ 2022-03-18 16:18 leochan007 阅读(369) 评论(0) 推荐(0)
摘要:// encripe_test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <string> #include <iostream> using namespace std; //int key[] = { 1,2,3,4,5,6,7 }; in 阅读全文
posted @ 2022-03-09 21:27 leochan007 阅读(448) 评论(0) 推荐(0)
摘要://功能函数 #include <vector> using namespace std; vector<CString> g_vSysFonts; INT CALLBACK NEnumFontNameProc(LOGFONT* plf, TEXTMETRIC* /*ptm*/, INT /*nFo 阅读全文
posted @ 2020-12-01 13:44 leochan007
摘要:#include <fstream>//ifstream读文件,ofstream写文件,fstream读写文件 #include <string>//文本对象,储存读取的内容 #include <iostream>//屏幕输出cout #include <cstdlib>//调用system("pa 阅读全文
posted @ 2020-10-30 09:27 leochan007
摘要:// #include <vcl.h> #pragma hdrstop #include "Unit1.h" // #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; class CAppleDemo { publi 阅读全文
posted @ 2020-10-21 15:36 leochan007 阅读(173) 评论(0) 推荐(0)
摘要:1 #include "stdafx.h" 2 #include <iostream> 3 using namespace std; 4 template<typename T> 5 //整数或浮点数皆可使用 6 void bubble_sort(T arr[], int len,int index=0) 7 { 8 int i, j; T temp; 9 for (i = 0; i < len 阅读全文
posted @ 2019-10-17 13:18 leochan007 阅读(216) 评论(0) 推荐(0)