- 博客(21)
- 资源 (1)
- 收藏
- 关注
转载 CMake指令学习
http://www.wang-hj.cn/?p=2629这个博客写的比较全面常用变量:CMAKE_C_FLAGS:gcc编译选项 CMAKE_CXX_FLAGS:g++编译选项// 在CMAKE_CXX_FLAGS编译选项后追加-std=c++11set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") CMAKE_BUILD_TYPE:编译类型(Debug, Release) // 设定编译类型为debug,因为在调试时需要选择
2022-03-17 18:54:28
2020
原创 C++关于socket的client&server库创建流程
最终结果如图:生成的最终文件夹目录:├── CTcpClient.cpp├── CTcpClient.h├── CTcpServer.cpp├── CTcpServer.h├── libCTcpClient.a├── libCTcpServer.a├── testclientmain├── testclientmain.cpp├── testservermain└── testservermain.cpp其中test开头的文件是用来测试的文件:最终生成的client和s
2022-03-06 16:27:02
922
原创 排序---插入
函数:#include <stdio.h>//插入排序void insertsort(int *array, int len){ int ii,jj,temp; for(ii=1; ii<len; ii++) { temp=array[ii]; //保存待排序的值 for(jj=ii-1; jj>=0; jj--){ if(temp>=array[jj]) break; array[jj+1]=array[j
2022-01-03 11:23:19
730
原创 排序---选择
包括递归,非递归选择排序交换函数:#include <stdio.h>//交换函数void swap(int *a, int *b){ int temp; temp=*a; *a=*b; *b=temp; return;}主函数:int main(){ int array[]={56, 12, 45, 13, 90, 98, 134, 89, 2, 8}; //int array[]={1, 2, 3, 4, 5, 6, 7, 8,
2022-01-02 17:06:35
324
原创 排序--冒泡
包括:普通冒泡(优化后),递归冒泡(优化)主函数:int main(){ //int array[]={56, 12, 45, 13, 90, 98, 134, 89, 2, 8}; int array[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int len = sizeof(array)/sizeof(int); //打印排序前 printf("排序前:"); for(int i=0; i<len; i++) printf("%d
2022-01-02 15:19:39
263
原创 IPC/共享内存
1.有亲缘关系进程间通信(父子进程之间通信)#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<sys/shm.h>#include<signal.h>void myfunc( int signum){ return;}//通过共享内存实现父子进程间通信//父进程不断的写数据,子进程不断地读数据int main()...
2021-12-26 14:36:59
318
原创 进程间通信------>信号
代码:父进程一直打印,子进程10秒后发送信号,父进程执行信号对应的事件,然后父进程继续执行原来的打印#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<signal.h>#include<stdlib.h>void myfunc(int signum){ int i=0; while(i<5){ ...
2021-12-20 22:40:33
120
原创 C语言实现select
缺点:1.select同时监听的文件描述符的上限是1024个,如果非要改就重新编译Linux内核。优点:1.可以跨平台头文件:#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <unistd.h>#include <std
2021-12-19 23:33:27
1712
原创 有名管道mkfifo通信
创建一个管道文件:#include<stdio.h>#include<unistd.h>#include<stdlib.h>#include<sys/types.h>#include<sys/stat.h>//创建管道文件,可以在没有亲缘关系的进程间通信int main(){ int ret=0; ret=mkfifo("./myfifo", 0777); if(ret<0) {printf("cr...
2021-12-19 15:30:02
514
1
原创 无名管道pipe
管道文件是一个特殊的文件,是由队列来实现的。在IO文件中创建一个文件或者打开一个文件是由open来实现的,但是他不能创建管道文件,管道文件只能由pipe函数来创建1.管道中如果没有可读就阻塞2.管道中写满了就写阻塞3.管道读完就删除代码实现如下:#include<stdio.h>#include<unistd.h>#include<sys/types.h>//无名管道在父子进程间通信int main(){ int re...
2021-12-19 14:03:47
321
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人