![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言
afleshfish
这个作者很懒,什么都没留下…
展开
-
【c语言】连接mysql
连接mysql代码#include <stdlib.h>#include <stdio.h>#include <mysql.h>int main() { char *ip = "localhost"; char *username = "aa"; char *pwd = "1"; char *databaseName = "t_file"; // 数据库指针 MYSQL *co原创 2020-09-24 22:51:05 · 204 阅读 · 0 评论 -
【C语言】位操作
按位进行相关操作#include <stdio.h>#include <stdint.h>#include <inttypes.h>//typedef unsigned long long uint64_t;uint64_t bData;uint64_t a24;uint64_t b24;// 针对第几位进行与非运算,对应位置就是你想要的数据void offset_64(uint64_t *data, long lsize_t, int byte_原创 2020-09-20 17:03:10 · 142 阅读 · 0 评论 -
【c语言】用c实现类似python的split函数功能
实现split功能实现代码实现代码#include <stdio.h>#include <string.h>/* 参数解析: src: 需要切割的字符数组,一定要用数组,strtok的第一个参数用的数组 separator: 分隔符 dest: 存放的地址 num: 切割的个数*/void split(char *src,const char *separator,char **dest原创 2020-09-10 21:46:50 · 556 阅读 · 0 评论 -
【C语言】linux库-静态库和动态库的使用
分模块对于一般分模块的使用,可以直接用以下语句进行编译:gcc main.c a.c b.c只需要有a.h以及b.h的头文件,就可以直接进行编译,但是这样需要*.c文件的存在,这样造成文件过多。静态库1、将需要打包的文件生成*.o文件gcc a.c -c此时会生成一个a.o的文件。2.将a.o文件生成liba.a文件ar -rcs liba.a a.o3、使用gcc main.c -la -L ./ -o main意思是将liba.a这库里面的与main.c一起打包成main原创 2020-08-22 00:22:06 · 174 阅读 · 0 评论 -
【C语言】socket 通信编程
解析server端server端在tcp的通信中,需要做到以下6点:socket套接字的构造 socketint socket(int domain, int type, int protocol);domain:指定通信域;选择通信的协议族。type:类型,tcp为SOCK_STREAM,udp为SOCK_DGRAM。protocol:协议,一般为0,会自动适配通信域及类型的配置。在man手册中是这样解释protocol参数的:协议指定要与套接字一起使用的特定协议。通常只有一个协原创 2020-08-18 20:41:15 · 365 阅读 · 0 评论 -
【C语言】多线程
linux多线程的使用普通demo实例解析共享内存空间普通demo实例#include <pthread.h>#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <unistd.h>/*int pthread_create(pthread_t *thread, const pthread_attr_t *attr,原创 2020-08-18 15:27:39 · 159 阅读 · 0 评论 -
【C语言】进程-信号量
Demo实现#include <stdio.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>union semun { int val; /* Value for SETVAL */ struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */原创 2020-08-17 13:42:23 · 636 阅读 · 0 评论 -
【C语言】信号编程
c语言信号的使用signal函数sigaction函数signal函数使用signal函数方法是比较简单的,原型函数为:sighandler_t signal(int signum, sighandler_t handler);信号接收到的信号数字,然后就执行函数handler。使用kill -l查看命令的编号:asus@ubuntu:~/Desktop/c_file$ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTR原创 2020-08-17 10:13:02 · 588 阅读 · 0 评论 -
【C语言】进程通信-共享文件
进程1创建共享文件 代码#include <sys/ipc.h>#include <sys/types.h>#include <sys/shm.h>#include <stdio.h>#include <string.h>#include <unistd.h>//int shmget(key_t key, size_t size, int shmflg);int main(){ char *s原创 2020-08-16 23:25:51 · 702 阅读 · 0 评论 -
【C语言】消息队列
C-queue读取消息队列代码消息队列 写 代码读取消息队列代码#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include <stdio.h>//int msgget(key_t key, int msgflg);//ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,//原创 2020-08-16 20:10:49 · 4243 阅读 · 0 评论 -
[C] pipe以及fork使用
进程与管道的使用参考原文链接: https://blog.csdn.net/nodeathphoenix/article/details/23284157?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2allbaidu_landing_v2~default-1-23284157.nonecase#include <stdio.h>#include <unistd.h>#include <原创 2020-08-12 11:16:15 · 813 阅读 · 0 评论 -
C语言实现文本操作
C语言实现文本操作代码配置文件代码#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <string.h>#include <stdlib.h>int main(int argc, char **argv){ const ch原创 2020-08-08 20:35:32 · 325 阅读 · 0 评论