随笔分类 - C语言学习
摘要:服务器创建共享内存 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<Windows.h> 4 5 #define SIZE 4096 6 //指针标识首地址 7 LPVOID lpdata = NULL; 8 9 10 void main()
阅读全文
摘要:运行截图: 把cgi编码转为char*类型 1 //把cgi编码转为char*类型 2 char* change(char *str) 3 { 4 //分配内存 5 char *tempstr = malloc(strlen(str) + 1); 6 7 //x是tempstr的下标,y是str的下
阅读全文
摘要:压力测试截图: 云端 定义管道缓存区大小,最多连接数量(线程个数),当前线程个数,管道名字 1 //缓冲区大小 2 #define SIZE 4096 3 //最多连接数量 4 #define MAX_CONNECT 128 5 //一开始有10个线程存在 6 int startthreadnum
阅读全文
摘要:服务器端 创建邮槽 1 //名称,数量 等待时间 安全属性 2 HANDLE hmailslot = CreateMailslotA(MAILSLOT, 0, MAILSLOT_WAIT_FOREVER, NULL); 获取邮槽信息 1 DWORD dxNextsize = 0;//标识最大的数据大
阅读全文
摘要:CGI编码 1 "%D6%DC%C8%F0%B8%A3"; 转换到字符串中: 1 //CGI编码转到char类型的tmpstr中中 2 char* change(char *str) 3 { 4 //分配内存 5 char *tempstr = malloc(strlen(str) + 1); 6
阅读全文
摘要:IO 创建文件并写文件 1 #define _CRT_SECURE_NO_WARNINGS 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include<io.h> 5 #include<fcntl.h>//文件打开 6 #include<sys/sta
阅读全文
摘要:"%[0-9A-Za-z] 读取一个集合,遇到不是数组或者大小写字母跳出 %*[^0-9A-Za-z]读取所有的非数字字母的字符,忽略 示例: 1 char strall [300]= "123sadsadasdas# 45613213213#yincheng01@163.com\n"; 2 cha
阅读全文
摘要:fseek 1 //文件路径 2 char path[150] = "1.txt"; 3 4 5 //FILE *pf = fopen(path, "a+");//尾部添加,文件指针在尾部 6 //FILE *pf = fopen(path, "w+");//文件指针在头部,清空内容 7 FILE
阅读全文
摘要:list.h 1 #define _CRT_SECURE_NO_WARNINGS 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <string.h> 5 6 //创建密码结点 7 typedef struct passinfo 8 { 9
阅读全文
摘要:数据挖掘 1 sscanf(str, "%d %s %s %d %d %s %s %s", &ph[i].id, ph[i].name, ph[i].sex, &ph[i].age, &ph[i].tall, ph[i].study, ph[i].mary, ph[i].where); 完整代码
阅读全文
摘要:ferror检测文件异常 perror提示文件错误信息 clearerr清除异常,让文件指针回到开头 完整代码
阅读全文
摘要:fprintf 1 //从读文件中提取字符串到info1.user和info1.password中 2 fscanf(pfr, "%s%s", info1.user, info1.password); fscanf 1 //格式化写入到文件中 2 fprintf(pfw, "%d %s %s\n",
阅读全文
摘要:1 //两个步骤,第一步读取文件,并且初始化索引结构体,把初始化的索引结构体写入到文件,第二步,读取这个文件到索引结构体 2 //并对这个结构体进行快速排序,得到顺序的索引,再写入文件 3 #define _CRT_SECURE_NO_WARNINGS 4 #include 5 #include 6 7 char path[256] = "QQ.txt"; 8 ...
阅读全文
摘要:问题引出: //有限的额内存情况怎么干活//索引载入内存,多线程//索引映射为内存 一.载入内存,按行读取进行多线程 定义路径以及其他信息 1 char path[256] = "kaifangX.txt"; 2 char indexpath[256] = "indexkf.txt"; 3 #def
阅读全文
摘要:1 #include 2 #include 3 #include 4 5 char path[256] = "kaifang.txt"; 6 7 void main() 8 { 9 //路径,读写, 10 HANDLE hfile = CreateFileA(path, GENERIC_READ |...
阅读全文
摘要:运行结果: 内存使用情况: 写入文件排序好的数据: 创建文件地址以及创建十一级指针 1 char *path = "QQ.txt"; 2 char *sortpath = "QQchiguowei2018.txt"; 3 //创建十一级指针 4 char *********** allP = NUL
阅读全文
摘要:一.文件载入内存进行多线程检索 获取并定义行数以及定义索引和文本的路径 1 char path[256] = "kaifangX.txt"; 2 char indexpath[256] = "indexkaifangX.txt"; 3 #define N 20151574 索引的结构体 1 //索引
阅读全文
摘要:获取文件有多少行 1 //获取文件有多少行 2 int getN(char *path) 3 { 4 FILE *pf = fopen(path, "r"); 5 if (pf==NULL) 6 { 7 return -1; 8 } 9 else 10 { 11 int i = 0; 12 whil
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 //多线程多文件,实现线程的调度 9 //释放内存 10 //内存不够的情况,排队完成任务 11 12 //创建多线程结构体 13 stru...
阅读全文
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 char *path = "dangdangwang.txt"; 10 11 #define N 13180820 12 13 //...
阅读全文

浙公网安备 33010602011771号