C进阶
C开发特性和技巧总结
SteveRocket
总结技术,分享技术,交流技术,我们一起学习,韶华易逝......
展开
-
系统函数C字符串的实现(9):strrchr
//函数名: strrchr// 功 能 : 在串中查找指定字符的最后一个出现// 用 法 : char *strrchr(char *str, char c);char *mystrrchr(char *str, char c){ char *p = NULL;//保存找到的字符的地址 //尾部指针 for (char*px=str+strlen(str) ;px>=str;原创 2015-08-15 22:50:06 · 904 阅读 · 0 评论 -
系统函数C字符串的实现(8):strlwr与strupr
字符串大小写转换void mystrlwr(char * _Str){ if (*_Str == '\0') { return; } else { if (*_Str >= 'A' && *_Str原创 2015-08-15 23:06:07 · 1003 阅读 · 0 评论 -
系统函数C字符串的实现(10):strcat
字符串拼接strcatchar *mystrcat(char *dest,const char *source){ char *pstart = dest; while (*pstart != '\0') { pstart++; } //从尾部 while ((*pstart++)=(*source++)) { }}void main(){ char str1[22]原创 2015-08-16 01:47:06 · 717 阅读 · 0 评论 -
系统函数C字符串的实现(15):strncmp
static void change(char *pch){ if (*pch >= 'A' && *pch原创 2015-08-19 18:38:46 · 512 阅读 · 0 评论 -
通过劫持系统函数malloc和free实现实时检测内存防泄漏(初级)
int i = 0;void * mymalloc(size_t _Size){ i++; void *p = malloc(_Size); return p;}void myfree(void * _Memory){ i--; free(_Memory);}//内存防泄漏 通过劫持系统的malloc与free函数实现 检测内存泄露void main(){原创 2015-08-18 16:55:05 · 875 阅读 · 1 评论 -
劫持系统函数system
#include "detours.h"#pragma comment(lib,"detours.lib")int(*poldsystem)(const char *_Command) = system;int newsystem(const char*_Command){ printf("你执行的是:%s\n", _Command); poldsystem(_Command);原创 2015-08-08 00:27:35 · 559 阅读 · 1 评论 -
工作经验总结之C语言关键字的作用、特性和使用方式
关键字(keyword)属于保留字,是整个语言范围内预先保留的标识符。每个C++关键字都有特殊的含义。经过预处理后,关键字从预处理记号(preprocessing-token)中区别出来,剩下的标识符作为记号(token),用于声明对象、函数、类型、命名空间等。不能声明与关键字同名的标识符。C语言简洁、紧凑,使用方便、灵活。ANSI C标准C语言共有32个关键字,9种控制语句,程序书写形式自由,区分大小写。把高级语言的基本结构和语句与低级语言的实用性结合起来。 C 语言可以像汇编语言一样对位、字节和地址进行原创 2023-05-16 07:00:00 · 1910 阅读 · 0 评论 -
封装 动态数组库 生成企业级lib实际应用库
封装企业级数组库,并成功生成相应的静态lib库,可直接用来调用并成功使用,实现数组的基本功能和操作原创 2015-08-04 23:57:22 · 487 阅读 · 1 评论 -
封装 数组库(简易)
声明部分 myarray.h#pragma once#include #include #include #define datatype intstruct array{ datatype *pstart;//数组首地址 int length;//长度 int sortstat;//有序或者无序 ,0无序,1有序};struct Res{ datatype **原创 2015-08-02 23:39:53 · 431 阅读 · 1 评论 -
封装 数组库二次实现字符串数组
字符串数组库 声明部分#pragma once#include #include #include #include #define datatype char *struct array{ datatype *pstart;//数组首地址 int length;//长度 int sortstat;};void init(struct array *parr);voi原创 2015-08-03 00:55:56 · 366 阅读 · 1 评论 -
封装 链表
linknode.h#include #include typedef struct student{ int num; float score; struct student *pNext;//用于存储下一个节点的地址}ST;//函数声明void add(ST **phead, int inum, float iscore);//函数声明 传入头结点的地址 然后插入数据原创 2015-07-29 02:18:35 · 679 阅读 · 1 评论 -
递归:多种方法实现进制转换,实现系统原函数_itoa()
实现方式一:void to_2(int num){ if (!num) { return 0; } else { to_2(num / 2); printf("%d ", num % 2); }}void to_8(int num){ if (!num) { return 0; } else { to_8(num / 8); printf("原创 2015-08-07 22:51:18 · 876 阅读 · 0 评论 -
希尔排序(简单)
void show(int*arr,int length){ for (int i = 0; i < length; i++) { printf("%d ", arr[i]); }}void shellsort(int *arr,int length){ //选择增量 int add = length / 2; while (add>=1)//增量终止条件 {原创 2015-08-12 00:16:22 · 342 阅读 · 0 评论 -
二分查找法 与 拉格朗日插值查找法
二分查找法:#define M 1024void search(int a[M], int num){ int tou = 0; int wei = M - 1; int zhong; int flag = -1; int ci = 0; while (tou原创 2015-08-01 07:12:17 · 1417 阅读 · 1 评论 -
快速排序:数组
void Swap50(int *p1, int *p2){ int temp = *p1; *p1 = *p2; *p2 = temp;}void show51(int *p, int length){ printf("\n"); for (int *px = p; px < p + length; px++) { printf("%d ", *px); }}v原创 2015-08-07 22:23:18 · 434 阅读 · 0 评论 -
C实现插入排序
void main(){ int a[10] = { 1, 8, 9, 45, 15, 67, 8, 15, 4, 23 }; for (int i = 0; i < 10 - 1; i++) { int temp = a[i]; int j = i; while (j>0 && a[j - 1] > temp) { a[j] = a[j - 1]; j--原创 2015-08-01 07:09:12 · 340 阅读 · 1 评论 -
选择排序:实现输出数组的最小值以及次小值,实现数组的排序
选择排序算法: #define N 10 time_t ts; unsigned int data = time(&ts); srand(data); int a[N]; for (size_t i = 0; i < N; i++) { a[i] = rand() % 100 + 50; printf("%d ", a[i]); } //选择排序 int kmax原创 2015-08-09 03:20:31 · 855 阅读 · 0 评论 -
编译原理:实现高级表达式计算器(初级)
#define _CRT_SECURE_NO_WARNINGS#include #include #include //处理空格void delspace(char *str){ char *p1 = str; char *p2 = str; while ((*p1 = *(p2++)) != '\0') { if (*p1 != ' ') { p1++;原创 2015-08-16 13:36:21 · 2299 阅读 · 3 评论 -
C99数组
数组: int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12 }; printf("%d\n", (*(a + 1)));//行指针 输出地址 printf("%d\n", ( *(a + 1)[1] ) );//(a + 1)[1] *(a+1+1) printf("%d\n", ( (*(a + 1)) [1]));/原创 2015-08-09 03:01:32 · 535 阅读 · 0 评论 -
内存管理:使用链式栈实现内存的有效管理与监控
运用链表的基本操作使用内存的管理,用于对所有C项目的内存的有效管理以及检测内存泄露问题。原创 2015-08-05 20:21:59 · 401 阅读 · 0 评论 -
冒泡排序:在随机产生的数组中查找最值,实现数组的排序
冒泡排序算法: time_t ts; unsigned int data = time(&ts); srand(data); int a[100]; printf("随机数组元素:\n"); for (int i = 0; i < 100; i++) { a[i] = rand() % 100; printf("%d ", a[i]); } printf("\n输入要原创 2015-08-09 03:17:06 · 472 阅读 · 0 评论