- 博客(62)
- 收藏
- 关注
原创 Linux虚拟内存空间布局
代码段:通常存放程序中的代码和常量。数据段:通常存放程序中的初始化后的全局变量和静态变量。BSS段:通常存放程序中的未初始化的全局变量和静态变量。堆:通常用来存放程序中进行运行时被动态分配的内存段。栈:通常用来存放程序运行时的栈帧,包含局部变量、函数形参、数组、函数返回值、返回地址等等。...
2020-09-25 09:00:36 194
原创 C语言结构体所占用的字节数如何计算
结bai构体的数据类型的有点多我们就不啰嗦了,直du接来看相同数据结构体的几种书zhi写的格式吧。格式一:struct tagPhone{ char A; int B; short C;}Phone;格式二:struct tagPhone{ char A; short C; int B;}Phone2;格式三:struct tagPhone3{ char A; char B[2];
2020-08-19 08:26:55 2738
转载 对于二维数组a[3][3]中a,&a,a[0],&a[0],&a[0][0]的区别和含义
对于一个二维数组a[3][3],分别将其a,&a,a[0],&a[0],&a[0][0]值打印出来,会发现其值都相等,但是各自的含义不同
2020-06-10 11:23:46 830
原创 混音算法
Wav文件直接反映了一个声音在每个时刻的大小值,比如说以下一段波形:我们按每人0.1秒取一点,得到的wav文件数值就是0,1,1,-1,0,1。因此,假如我们能把许多Wav文件的数据直接相加,你听到的就是所有的声音,这就是混音器的原理。Step 1, Get the Raw data of the two files, (Example, of the sample 8bit and 8Kh, means one sample is of 8bit)Step 2 Let the two audio s
2020-06-10 09:33:46 569
原创 关于C++重载时候用&
c++中有些重载运算符为什么要返回引用,单单为了避免析构再构造吗? 不是。「有些」重载运算符要返回的引用,是为了返回它本身。如class TestClass {private:int number;public:TestClass& operator+=(const TestClass& rhs) {number += rhs.number;return *th...
2020-04-16 09:34:25 798
原创 linux下ipcs和ipcrm命令详解
取得ipc信息:ipcs [-m|-q|-s]-m 输出有关共享内存(shared memory)的信息-q 输出有关信息队列(message queue)的信息-s 输出有关“遮断器”(semaphore)的信息ipcs -mIPC status from as of 2007年04月10日 星期二 18时32分18秒 CSTT ID ...
2020-04-03 19:10:21 315
原创 C语言system函数
函数名: system功 能: 发出一个DOS命令用 法: int system(char *command);system函数已经被收录在标准c库中,可以直接调用。例如:#include<stdio.h>#include<stdlib.h>int main(){printf(“About to spawn and run a DOS command\n”...
2020-04-03 15:02:03 248
原创 C语言中缓存详解
为什么要引入缓冲区比如我们从磁盘里取信息,我们先把读出的数据放在缓冲区,计算机再直接从缓冲区中取数据,等缓冲区的数据取完后再去磁盘中读取,这样就可以减少磁盘的读写次数,再加上计算机对缓冲区的操作大大快于对磁盘的操作,故应用缓冲区可大大提高计算机的运行速度。又比如,我们使用打印机打印文档,由于打印机的打印速度相对较慢,我们先把文档输出到打印机相应的缓冲区,打印机再自行逐步打印,这时我们的CPU可...
2020-03-31 11:50:30 752
原创 在linux64位机器上编译时遇到的两个问题
wxtSi_gw/wxtGw_receive.c: In function ‘void* ListenLoop(void*)’:wxtSi_gw/wxtGw_receive.c:785: error: cast from ‘void*’ to ‘int’ loses precisionListenLoop是一个线程函数,通过void的参数,将一个整型值传进来,然后在函数内部做了强制转换voi...
2020-03-24 14:35:15 264
原创 原创 linux下c++ lesson26 容器-算法
1-遍历算法.cpp#include <iostream>#include <vector>#include <algorithm>using namespace std;void show(int x){ cout << x << endl;}class print{public: void operato...
2020-03-21 10:54:31 139
原创 原创 linux下c++ lesson25 容器map
1-map的使用.cpp#include <iostream>#include <map>using namespace std;int main(){ map<int, string> m; //key是int类型 value是string类型 m.insert(pair<int, string>(3, "aa"));...
2020-03-21 10:52:35 206
原创 原创 linux下c++ lesson24 容器set
1-set的使用.cpp#include <iostream>#include <set>using namespace std;class Student{private: int id; string name;public: Student(int i, string n); void show()const; bool operator...
2020-03-20 18:11:08 196
原创 原创 linux下c++ lesson23 容器priority_queue
1-优先队列.cpp#include <iostream>#include <queue>#include <time.h>#include <stdlib.h>using namespace std;int main(){ //priority_queue<int> p; //priority_queue<i...
2020-03-19 21:26:41 132
原创 原创 linux下c++ lesson22 容器-stack&queue
1-栈.cpp#include <iostream>#include <stack>#include <stdlib.h>#include <time.h>using namespace std;int main(){ stack<int> s; srand(time(NULL)); int num; for ...
2020-03-19 09:39:40 121
原创 原创 linux下c++ lesson21 容器list
1-list.cpp#include <iostream>#include <list>#include <string.h>using namespace std;class Student{private: int id; char name[32];public: Student(){} Student(int i, const...
2020-03-18 22:30:52 152
原创 原创 linux下c++ lesson20 容器-vector和deque
1-vector.cpp#include <iostream>#include <vector>using namespace std;int main(){ int data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; vector<int> v1; //创建数组对象(模板类) 无参构造函数 v...
2020-03-13 16:54:19 174
原创 原创 linux下c++ lesson19 容器string
1-string的构造.cpp#include <iostream>#include <string>using namespace std;int main(){ string s1; //无参构造函数 string s2("helloworld"); //有参构造函数 string s3...
2020-03-12 21:29:28 134
原创 原创 linux下c++ lesson18 io操作
1-标准输入流.cpp#include <iostream>using namespace std;int main(){ char ch; char buf[32] = {0}; /*cin >> ch; cout << ch << endl; ch = cin.get(); cout << ch <&...
2020-03-12 09:43:29 158
原创 原创 linux下c++ lesson17 强制类型转换
1-static_cast.cpp#include <iostream>using namespace std;class Parent{};class Child : public Parent{};int main(){ int a = 1; char ch = 'x'; a = static_cast<int>(ch); //用...
2020-03-11 16:20:59 203
原创 原创 linux下c++ lesson16异常处理机制
1-异常基本语法.cpp#include <iostream>using namespace std;int Div(int x, int y){ if (0 == y) { //return -1; //throw 0; //抛出异常 throw 'a'; } return x / y;}int main(){ int a, ...
2020-03-11 16:19:02 161
原创 原创 linux下c++ lesson15 类模板
1-类模板.cpp#include <iostream>using namespace std;template <typename T, typename U>class Test{private: T a; U b;public: Test(T a, U b) { this->a = a; this->b = b; } ...
2020-03-09 10:39:17 129
原创 原创 linux下c++ lesson14 函数模板
1-函数模板的概念.cpp#include <iostream>using namespace std;/*int add(int x, int y){ return x + y;}double add(double x, double y){ return x + y;}*/template <typename T> //声明虚拟类型...
2020-03-09 10:37:19 111
原创 原创 linux下c++ lesson13 运算符重载基础
1-逻辑运算符.cpp#include <iostream>using namespace std;int f1(){ cout << "this is f1" << endl; return 0;}int f2(){ cout << "this is f2" << endl; return 1;}cla...
2020-03-08 16:31:27 124
原创 原创 linux下c++ lesson12 运算符重载基础
1-运算符重载概念.cpp#include <iostream>using namespace std;class Complex{ //friend Complex operator+(const Complex &c1, const Complex &c2);private: int a; //实部 int b; //虚部publi...
2020-03-08 16:29:16 170
原创 原创 linux下c++ lesson11 动态类型识别
1-动态类型识别.cpp#include <iostream>using namespace std;class Parent{private: int a;};class Child : public Parent{public: int array[102400];};void f(Parent *p){ Child *c = (Child *...
2020-03-08 16:26:19 129
原创 原创 linux下c++ lesson10 多态
1-问题引出.cpp#include <iostream>using namespace std;class Parent{public: void show() { cout << "this is parent" << endl; }};class Child : public Parent{public: void s...
2020-03-08 16:21:43 107
原创 原创 linux下c++ lesson9 多继承
1-多继承的概念.cpp#include <iostream>using namespace std;class Airplane {protected: int high;public: Airplane() { cout << "飞机的构造函数" << endl; high = 100; } void show() { ...
2020-03-07 10:25:51 193
原创 原创 linux下c++ lesson8 继承
1-继承的语法.cpp#include <iostream>#include <cstring>using namespace std;class Person //父类或者基类{//private:protected: //保护权限:类的内部可以访问,派生类内部可以访问,类的外部不能访问 char name[32]; int age;pu...
2020-03-04 10:02:49 135
原创 原创 linux下c++ lesson7 面向对象模型
1-static.cpp#include <iostream>using namespace std;class Student{public: static int count; //静态成员变量 所有对象共享同一个静态成员变量private: int id;public: Student() { count++; id = count; }...
2020-02-28 17:23:21 116
原创 原创 linux下c++ lesson6 动态对象创建
1-malloc.cpp#include <iostream>#include <stdlib.h>using namespace std;class Test{public: Test() { cout << "Test构造函数" << endl; } ~Test() { cout << "Test析...
2020-02-27 09:37:57 197
原创 原创 linux下c++ lesson5 构造函数和析构函数
1-构造函数.cpp#include <iostream>#include <cstdlib>using namespace std;class Array{private: int *data; //数组的起始地址 int size; //数组的容量public: Array(); //无参构造函数 函数名和类名一样 没有返回...
2020-02-24 17:35:59 135
原创 linux下c++ lesson4 类的封装
1-圆的面积.cpp#include <iostream>using namespace std;/*struct Circle //结构体{ int r; double s;};*/class Circle //类{private: int r; //成员变量 属性 double s;public: void ...
2020-02-23 16:57:12 109
原创 linux下c++ lesson3 C++函数
1-默认参数.cpp#include <iostream>using namespace std;void print(int x, int y = 1, int z = 2) //一旦使用了默认参数,后面的所有参数都得加上默认参数{ cout << x << y << z << endl;}int main()...
2020-02-20 18:22:23 112
原创 linux下c++ lesson2 const和引用
1-const.cpp#include <iostream>using namespace std;void f(){ #define b 100 const int c = 200;}int main(){ const int a = 1; //C++中,const修饰的是常量,存放在符号表中 //a++; int *p = (int *)&am...
2020-02-18 16:07:57 132
原创 linux下c++ lesson1 c到c++
1-helloworld.cpp#include <iostream> //包含头文件 输入输出流using namespace std; //使用标准命名空间int main(){ cout << "helloworld" << endl; //cout 标准输出流对象 << 输出运算符 endl 换行 ...
2020-02-16 13:00:32 164
原创 linux下shell的基础编程和高级编程
有起要注意空格等问题,这个一开始学的时候特别容易出错,然后导致查了半天!!1-helloworld.sh#!/bin/bash#使用/bin/bash来解析脚本echo "helloworld"2-变量.sh#!/bin/bashnum=10name="jack"age=22sex='male'echo $numecho "name : $name age :...
2020-02-14 14:28:02 146
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人