文章分类 -  C语言

C语言中联合体
摘要:联合体union 当多个数据需要共享内存或者多个数据每次只取其一时,可以利用联合体(union)。在C Programming Language 一书中对于联合体是这么描述的: 1)联合体是一个结构; 2)它的所有成员相对于基地址的偏移量都为0; 3)此结构空间要大到足够容纳最"宽"的成员; 4)其 阅读全文

posted @ 2016-08-15 15:22 A-祥子 阅读(974) 评论(0) 推荐(0)

gcc编译器和g++编译器的区别:
摘要:gcc 最开始的时候是 GNU C Compiler, 如你所知,就是一个c编译器。但是后来因为这个项目里边集成了更多其他不同语言的编译器,GCC就代表 the GNU Compiler Collection,所以表示一堆编译器的合集。 g++则是GCC的c++编译器。现在你在编译代码时调用的gcc 阅读全文

posted @ 2016-08-10 12:50 A-祥子 阅读(523) 评论(0) 推荐(0)

C语言中字符和数字转换函数:itoa()和atoi()
摘要:C语言itoa()函数和atoi()函数详解(整数转字符C实现) C语言提供了几个标准库函数,可以将任意类型(整型、长整型、浮点型等)的数字转换为字符串。 1.int/float to string/array: C语言提供了几个标准库函数,可以将任意类型(整型、长整型、浮点型等)的数字转换为字符串 阅读全文

posted @ 2016-08-10 01:19 A-祥子 阅读(272) 评论(0) 推荐(0)

区别文件描述符(Linux)和文件指针(C语言)
摘要:文件描述符:在linux系统中打开文件就会获得文件描述符,它是个很小的正整数。每个进程在PCB(Process Control Block)中保存着一份文件描述符表,文件描述符就是这个表的索引,每个表项都有一个指向已打开文件的指针。 文件指针:C语言中使用文件指针做为I/O的句柄。文件指针指向进程用 阅读全文

posted @ 2016-08-09 23:50 A-祥子 阅读(675) 评论(0) 推荐(0)

KMP算法解释篇
摘要:初尝KMP算法--这个味道酸爽! 文章借鉴自http://www.cnblogs.com/c-cloud/p/3224788.html 1.kmp算法的原理: 本部分内容转自:http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2 阅读全文

posted @ 2016-08-09 20:02 A-祥子 阅读(182) 评论(0) 推荐(0)

查找一组数据中第n大的数的位置方法:
摘要:#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h> //打印函数void Print(int *arr, int len){ int *p = arr; int n = len; w 阅读全文

posted @ 2016-08-09 16:54 A-祥子 阅读(600) 评论(0) 推荐(0)

C语言文件读写,单个字符读写,字符串读写,二进制码流读写
摘要:#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>#include<sys/types.h> struct Message{ char name[10]; char age; }; 阅读全文

posted @ 2016-08-09 13:06 A-祥子 阅读(4073) 评论(0) 推荐(1)

#法创建二叉树,NULL的地方输入‘#’
摘要:#define _CRT_SECURE_NO_WARNGINGS#include<stdio.h>#include<stdlib.h>#include<string.h> typedef struct bintree{ char c; struct bintree * lchild; struct 阅读全文

posted @ 2016-08-08 23:51 A-祥子 阅读(478) 评论(0) 推荐(0)

二叉树的拷贝和释放
摘要:#define _CRT_SECURE_NO_WARNGINGS#include<stdio.h>#include<stdlib.h>#include<string.h> typedef struct bintree{ char c; struct bintree * lchild; struct 阅读全文

posted @ 2016-08-08 20:33 A-祥子 阅读(279) 评论(0) 推荐(0)

二叉树的前序、中序、后序遍历,以及叶子数目,树的深度
摘要:#define _CRT_SECURE_NO_WARNGINGS#include<stdio.h>#include<stdlib.h>#include<string.h> typedef struct bintree{ char c; struct bintree * lchild; struct 阅读全文

posted @ 2016-08-08 19:51 A-祥子 阅读(329) 评论(0) 推荐(0)

几种基本排序算法(二)希尔,快排,归并------直接上代码
摘要:希尔排序: #include<stdio.h>#include<stdlib.h>#include<string.h>#include<time.h> #define Max 40//交换数据void swap(int *str, int pos1, int pos2){ int tmp = str 阅读全文

posted @ 2016-08-08 01:11 A-祥子 阅读(124) 评论(0) 推荐(0)

几种基本排序算法(一):冒泡,选择,插入------直接上代码
摘要:冒泡排序: #include<stdio.h>#include<stdlib.h>#include<string.h>#include<time.h> #define Max 10//交换数据void swap(int *str, int pos1, int pos2){ int tmp = str 阅读全文

posted @ 2016-08-07 11:25 A-祥子 阅读(308) 评论(0) 推荐(0)

双向链表的基本操作回顾(代码)
摘要:头文件: #ifndef DOUBLELINKLIST_H#define DOUBLELINKLIST_H #include<stdio.h>#include<stdlib.h> //链表结点typedef struct _DOUBLELISTNODE{ void* data; struct _DO 阅读全文

posted @ 2016-08-06 20:22 A-祥子 阅读(246) 评论(0) 推荐(0)

C语言文件操作常用的库函数整理:
摘要:fputc(char a,fp); 将字符写入文件中; b=fgetc( fp);由文件中读取字符; fputs(const char *s,FILE *stream);将一指定的字符串写入文件内 fgets(char *s,int size,FILE *stream);由文件中读取一定字符串 si 阅读全文

posted @ 2016-08-04 00:53 A-祥子 阅读(643) 评论(0) 推荐(0)

strtok函数实现的文章,借鉴过来,原文章网址:http://blog.csdn.net/helpxs/article/details/6958975/
摘要:strtok函数的使用是一个老生常谈的问题了。该函数的作用很大,争议也很大。以下的表述可能与一些资料有区别或者说与你原来的认识有差异,因此,我尽量以实验为证。交代一下实验环境是必要的,winxp+vc6.0,一个极端平民化的实验环境。本文中使用的源代码大部分来自于网络,我稍加修改作为例证。当然,本人 阅读全文

posted @ 2016-08-03 11:00 A-祥子 阅读(344) 评论(0) 推荐(0)

导航