C/C++
文章平均质量分 81
平凡的兵
AI的实践者
展开
-
memset, memcpy, strcpy
1. memsetvoid *memset(void *s, int ch, size_t n);将s中前n个字节 (typedef unsigned int size_t )用 ch 替换并返回 s 。memset:作用是在一段内存块中填充某个给定的值,它是对较大的结构体或数组进行清零操作的一种最快方法2. memcpyvoid *memcpy(void转载 2015-03-26 22:44:39 · 338 阅读 · 0 评论 -
文件操作fopen, fclose, fread, fwrite, fseek, ftell
fopenFILE * fopen ( const char * filename, const char * mode );Open fileOpens the file whose name is specified in the parameter filename and associates it with a stream that can be identif转载 2015-04-05 22:46:55 · 898 阅读 · 0 评论 -
C/C++动态二维数组的内存分配和释放
C语言[cpp] view plaincopy//二维数组动态数组分配和释放 //数组指针的内存分配和释放 //方法一 char (*a)[N];//指向数组的指针 a = (char (*)[N])malloc(sizeof(char [N]) * m); free(a); //方法二转载 2015-04-13 20:42:18 · 855 阅读 · 0 评论 -
C++ vector
在c++中,vector是一个十分有用的容器,下面对这个容器做一下总结。1 基本操作(1)头文件#include.(2)创建vector对象,vector vec;(3)尾部插入数字:vec.push_back(a);(4)使用下标访问元素,cout(5)使用迭代器访问元素.vectorint>::iterator it;for(it=ve转载 2016-02-19 08:48:10 · 333 阅读 · 0 评论 -
虚函数
虚函数为了重载和多态的需要,在基类中是有定义的,即便定义是空,所以子类中可以重写也可以不写基类中的函数!纯虚函数在基类中是没有定义的,必须在子类中加以实现,很像java中的接口函数!虚函数引入原因:为了方便使用多态特性,我们常常需要在基类中定义虚函数。class Cman{public:virtual void Eat(){……};void Move转载 2016-01-22 16:55:07 · 390 阅读 · 0 评论 -
spiralMatrix
/** * Note: The returned array must be malloced, assume caller calls free(). */int* spiralOrder(int** matrix, int matrixRowSize, int matrixColSize) { int* vector = malloc( sizeof(int) * matrixR原创 2016-07-17 11:42:59 · 438 阅读 · 0 评论 -
spiralMatrixII
/** * Return an array of arrays. * Note: The returned array must be malloced, assume caller calls free(). */int** generateMatrix(int n) { int x0 = 0; // top left x int y0 = 0; // to原创 2016-07-17 18:16:45 · 412 阅读 · 0 评论 -
openfst使用
1. 安装本人下载的是openfst-1.5.1版本(1) ./configure(2) make(3) sudo make install查看/usr/local/bin目录是否生成可执行文件,以及/usr/local/lib目录生成动态库文件libfst.so2. C++程序#include using namespace fst;int main()原创 2016-02-23 17:18:45 · 11502 阅读 · 2 评论