![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
泉小猪
这个作者很懒,什么都没留下…
展开
-
malloc与new
new与malloc(收集整理from web)1.malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符。它们都可用于申请动态内存和释放内存2.对于非内部数据类型的对象而言,光用maloc/free无法满足动态对象的要求。对象在创建的同时要自动执行构造函数,对象在消亡之前要自动执行析构函数。由malloc/free是库函数而不是运算符,不转载 2013-04-15 22:31:33 · 242 阅读 · 0 评论 -
memset
void *memset(void *s,int ch,size_t n);函数解释:将 s 中前 n 个字节用 ch 替换并返回 s 。 搞反了 ch 和 n 的位置. 一定要记住如果要把一个char a[20]清零,一定是 memset(a,0,20);原创 2013-04-15 22:49:40 · 1292 阅读 · 0 评论 -
substr与assign
C++中substr()函数用法substr(起始位置,长度)#include#includeusing namespace std;main(){string s("12345asdf");string a=s.substr(0,4); //获得字符串s中 从第0位开始的长度为4的字符串cout}输出结果为:1234as转载 2013-04-23 19:24:05 · 748 阅读 · 0 评论 -
单链表插入删除等操作
#include "stdafx.h"#includeusing namespace std;typedef struct student//定义链表结构体{int data;struct student *next;}node;node *creat()//建立链表{node *head,*p,*s;int x,cycle=1;head=(node原创 2013-04-17 15:34:29 · 429 阅读 · 0 评论 -
循环字符串
#include "stdafx.h"#includeusing namespace std;void LoopMove(char *pStr,int steps){int n=strlen(pStr)-steps;coutchar temp[127];memcpy(temp,pStr+n,steps);memcpy(temp+steps,pStr,n)原创 2013-04-19 11:57:16 · 533 阅读 · 0 评论