
C/C++
minwenping
这个作者很懒,什么都没留下…
展开
-
c++ 简单实现双向链表
头文件定义:#pragma once#include <stdlib.h>#include <stdio.h>#include <functional>using namespace std;//定义链表节点 typedef struct CIRCLE_NODE{ CIRCLE_NODE * next;}Node;//定义链表 typedef struct CIRCLE_LINK_LIST { Node header; int size;原创 2021-09-17 20:55:38 · 347 阅读 · 0 评论 -
C++ 仿函数绑定适配器<functional>
#include <vector>#include <functional>#include <algorithm>using namespace std;//绑定函数 的参数列表是指,参数列表+返回值struct PrintInfo2 :public binary_function<int,int,void> { //编译报错 具有类型“const _Fn”的表达式会丢失一些 const-volatile 限定符以调用“void...原创 2021-08-29 20:52:34 · 182 阅读 · 0 评论 -
函数指针的三种 定义和使用方式
#include <iostream>using namespace std;//函数 指针的使用int add(int a,int b) { cout << " add fuction called " << endl; return a + b;}int main(){ //1.定义函数类型 -- 返回值(类型名字)(参数列表)--这种格式 typedef int (FUNCTION)(int, int); //使用规则如下,先初.原创 2021-08-19 21:43:53 · 387 阅读 · 0 评论 -
动态分配结构体内存
struct Teacher{ char name[20];};//嵌套结构体struct Student{ int age; struct Teacher teacher;//内存大小,指针也是int类型}; //动态分配结构体内存 struct Student *p1 = (Student* )malloc(sizeof(struct Student)*原创 2017-12-16 23:31:19 · 7871 阅读 · 1 评论 -
Linux 上标准c复制文件
#include "stdafx.h"#include<stdio.h>#include<stdlib.h>int _tmain(int argc, _TCHAR* argv[]){ char *path = "C:\\Users\\Administrator\\Desktop\\original.PNG"; char *newpath = "C:\\Users\\Admin原创 2017-12-19 20:30:24 · 505 阅读 · 0 评论 -
c/c++字符串拼接追加复制,字符串和int相互转换,sscanf的转义
char s[100]="hello world"; //1.计算字符串的长度 int lenth= strlen(s); printf("length=%d\n",lenth); //2.字符串的拼接或追加 char s2[100]="abcefg"; strcat(s,s2);//将s2拼接到s后面字符串的指定长度拼接 char s[100]原创 2017-09-06 21:41:40 · 10698 阅读 · 0 评论 -
c/c++真伪随机数
伪随机数的产生#include <stdio.h>#include <stdlib.h>int main(void){ //c++的随机数使用 int i=0; for(i=0;i<11;i++) { int value=rand(); printf("%d\n",value); } return 0;}//每原创 2017-09-05 22:42:12 · 3934 阅读 · 1 评论 -
c/c++字符串的逆序,混合长度,祛除空格等处理
—–字符串的逆序—–int main(void){ //字符串的逆序 char string[100]="hello wrold"; //先计算字符串的长度 int lenth=0; while(string[lenth++]); lenth--;//减去最后一次的自增 printf("%d\n",lenth); int min=0;原创 2017-09-04 22:16:47 · 645 阅读 · 0 评论