- 博客(10)
- 收藏
- 关注
原创 多线程控制互斥锁与信号量
1.多线程编临界资源访问#define _GNU_SOURCE #include <pthread.h>#include <stdio.h>#include <unistd.h>#include <errno.h>int Num = 0;void *fun1(void *arg){ while(Num<3){ Num++; printf("%s :Num =
2020-11-16 16:13:50 163
原创 多线程创建、退出与回收
1.在程序中,可以通过函数,pthread_self,来返回当前线程的线程号,例程1给出了打印线程tid号获取线程号#include <pthread.h>pthread_t pthread_self(void);成功:返回线程号#include <stdio.h>#include <pthread.h>int main(){ pthread_t tid = pthread_self(); printf("tid = %ld
2020-11-16 13:56:22 495
原创 UDP编程
服务端代码:#include <sys/types.h> /* See NOTES */#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#include <stdio.h>#include <errno.h>#include <time.h>#in...
2020-11-15 18:01:15 53
原创 读老文件到新文件
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <stdio.h>int main(int argc,char **argv){ int fd_old,fd_new; char buf[1024]; int len; /* 1. 判断参数 */
2020-11-15 10:57:10 127
原创 设置环境变量PATH
1.如果不想设置环境变量echo $PATHsudo cp hello /usr/local/bin/hello2hello22.临时设置环境变量(只对当前终端有效)cp hello /home/book/export PATH= $PATH:/home/book3.永久设置方法(对当前用户有效)修改~/.bashrc vi ~/.bashrc在行尾添加: export PATH=$PATH:/home/book然后重启系统或重新登录4.永..
2020-11-14 13:43:47 245
原创 Makefile规则与示例
1.Makefiletest : main.c sub.c sub.hgcc -o tset main.c sub.c2.Makefiletest : main.o sub.ogcc -o test main.o sub.cmain.o : main.cgcc -c -o main.o main.csub.o : sub.cgcc -c -o sub.o sub.cclean:rm *.o test -f执行:make make clean3.Makefiletest ..
2020-11-13 10:21:55 140
原创 基于Wemos的wifi避障小车
#include <ESP8266WiFi.h>#define Dong1 D6#define Dong2 D7#define Zhuan1 D4#define Zhuan2 D5#define Echo D2#define Trig D8char* ssid = "HONOR9X"; //“wifi热点名称”char* passwd = "qwejklbnm"; //”wifi热点密码”int port
2020-11-10 18:37:35 245
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人