因为今天做那个MFC的编辑框有一些框就是要判断输入的是否是数值,一开始我就直接把编辑框那个NUMBER属性给设置了 然后发现 负数不能输入 我TM的差点脑袋都炸了然后就去百度搜索函数直接判断字符串数值包括小数,负数,整数这三个的,发现没有官方函数????好吧 然后我就去使用正则表达式来搞这个了 反正从c++11里就添加了正则表达式的支持#include <regex> #include <iostream> #include <string> //正则匹配数值包括负数 小数 整数 std::string str{ "-[0-9]+(....
工作中经常用到对文件行的操作,下面C++代码实现了通过行号读取指定的行数据,删除指定行数据,对指定行数据进行修改。复制过去可直接使用。/******************************************************** Copyright (C), 2016-2018, FileName: main Author: woniu201 Email: wangpengfei.201@163.com Created: 2018/08/31 Description: 文件操作:读...
删除文件目录函数:void myDeleteDirectory(CString directory_path) { CFileFind finder; CString path; path.Format(_T("%s/*.*"), directory_path); BOOL bWorking = finder.FindFile(path); while (bWorking) { bWorking = finder.FindNextFile(); if (finder.IsDirectory...
C++ STL 注意点1、存储内存所有的STL的容器的元素都是存储在堆中,所有的内存的开辟和释放都是容器自己解决的。整体内存分为:堆区域栈区域全局存储区:这其中BSS的没有初始化; DATA是初始化后的变量。文字常量区程序代码区2、常用的STL 容器总结(1)序列容器:一般常用的。vector:动态顺序容器。注意每次push元素,如果个数超过当前的capxxx容量值,会重新分配内存,内存是连续的;重新分配的时候之前的迭代器全部失效; 再次分配的时候,分配的大小是之前的1.5倍。list:双向链表,可在两头插入和删除stack:栈,LIFO后进先出结构deque:双端队列queue:单端队...
#include<fstream> #include<iostream> #include<string> #include <vector> using namespace std; vector< string> split(string str, string pattern) { vector<string> ret; if (pattern.empty()) return ret; size_t start = 0, index = str.find_first_of(pattern...
#include <iostream> #include <fstream> #include <string> #include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <sstream> #include <deque> using namespace std; string pattern = " "; int x; vector<...
C++文本文件读写程序(基本方式)//C++ code: #include <iostream> #include <fstream> #include <string> using namespace std; class file{ public: //按行读数据,不分行写入另外一个文件 bool fromShortToLong(string s_path,string d_path){ string buffer; fstream infile(s_path); fstream ou...
go递归遍历文件目录package main import ( "fmt" "io/ioutil" "log" ) //文件目录树形结构节点 type dirTreeNode struct { name string child []dirTreeNode } //递归遍历文件目录 func getDirTree(pathName string) (dirTreeNode, error) { rd, err := ioutil.ReadDir(pathName) ...
一、文件读取将整个文件读取到内存中package main import ( "flag" "fmt" "io/ioutil" ) func main() { //从命令行标记参数中获取文件路径 fptr := flag.String("fpath", "test.txt", "the file path to read from") flag.Parse() data, err := ioutil.Rea...