随笔分类 - c++
工作笔记
摘要:#include <iostream> #include <map> int main() { std::map<int, int> myMap = { {1, 100}, {2, 200}, {3, 300} }; void* ptr = &myMap; // 安全转换 + 检查 if (!ptr
阅读全文
摘要:#include <iostream> #include <chrono> #include <ctime> #include <iomanip> #include <sstream> int main() { // 获取当前时间点 auto now = std::chrono::system_cl
阅读全文
摘要:#define STRINGIFY(x) #x int someVariable = 10; std::cout << STRINGIFY(someVariable) << " = " << someVariable << std::endl;
阅读全文
摘要:#include <iostream> #include <sstream> #include <iomanip> #include <ctime> bool compareTimeStrings(const std::string& timeStr1, const std::string& tim
阅读全文
摘要:#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
阅读全文
摘要:#include <iostream> #include <fstream> int main() { std::ifstream sourceFile("source.txt", std::ios::binary); // 打开源文件 if (!sourceFile) { std::cout <<
阅读全文
摘要:新手VSCode配置C++20 Makefile教程1 快速入门 HTTP 代理服务器的设计与实现(C++)
阅读全文
摘要:// testfindfile.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include <windows.h> bool SearchFilesByWildcard(const WCHAR* wildcardPath)
阅读全文
摘要:// testmutex.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include "windows.h" HANDLE m_hMutex; #include<list> using namespace std; lis
阅读全文
摘要:C++中将string类型转换为double的方法:#include <iostream>#include <sstream> //使用stringstream需要引入这个头文件using namespace std;//模板函数:将string类型变量转换为常用的数值类型(此方法具有普遍适用性)t
阅读全文
摘要://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; }
阅读全文
摘要://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
阅读全文
摘要:#include <iostream> #include<direct.h> #include<io.h> bool CheckPathExist(std::string path) { if (access(path.c_str(), 0) == -1) { return false; } ret
阅读全文
摘要:// encripe_test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <string> #include <iostream> using namespace std; //int key[] = { 1,2,3,4,5,6,7 }; in
阅读全文
摘要://功能函数 #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
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号