09 2011 档案

摘要:开始结点:是指链表中的第一个结点,也就是没有直接前趋的那个结点。头指针:是一指向链表开始结点的指针(没有头结点时),单链表由头指针唯一确定,因此单链表可以用头指针的名字来命名。头结点:是在链表的开始结点之前附加的一个结点。有了头结点之后,头指针指向头结点,不论链表否为空,头指针总是非空。而且头指针的设置使得对链表的第一个位置上的操作与在表其他位置上的操作一致(都是在某一结点之后)。http://www.cnblogs.com/Jennifer/articles/2159484.htmlhttp://www.cnblogs.com/cpoint/archive/2010/12/20/191135 阅读全文
posted @ 2011-09-27 16:05 火腿骑士 阅读(427) 评论(0) 推荐(0) 编辑
摘要://程式名:LinkStack.c//程式功能:链栈的实现//功能描述:置栈空、判栈空、压栈、出栈、取栈顶元素//http://student.zjzk.cn/course_ware/data_structure/web/xianxingbiao/xianxingbiao2.3.1.2.htm#include<stdio.h>#include<stdlib.h>//包含exit();typedefcharDataType;//假定数据类型为字符typedefstructstacknode{DataTypedata;structstacknode*next;}StackN 阅读全文
posted @ 2011-09-27 13:45 火腿骑士 阅读(156) 评论(0) 推荐(0) 编辑
摘要:#ifndef DICTIONARY_H#define DICTIONARY_H#include "hashtable.h"typedef struct { HashTable *table;} Dictionary;Dictionary *dictionary_construct();void dictionary_destroy(Dictionary *dictionary);void dictionary_add_entry(Dictionary *dictionary, const char *key, const char *... 阅读全文
posted @ 2011-09-27 12:58 火腿骑士 阅读(3843) 评论(0) 推荐(0) 编辑
摘要:#ifndef HASH_TABLE_H#define HASH_TABLE_H#include "linkedlist.h"typedef struct { int capacity; LinkedList **elements; int seed;} HashTable;HashTable *hash_table_construct(int size);HashTable *hash_table_clone(HashTable *table);void has_table_destroy_clone(HashTable *table);void hash_table_d 阅读全文
posted @ 2011-09-27 12:57 火腿骑士 阅读(434) 评论(0) 推荐(0) 编辑
摘要:#ifndef STRING_H#define STRING_H#define STRING_DEFAULT_CHUNK_SIZE 256typedef struct { char *value; int length; int capacity; int chunk_size;} String;String *string_construct(const char *value);String *string_construct_from_int(int value);void string_destroy(String *string);void string_se... 阅读全文
posted @ 2011-09-27 12:52 火腿骑士 阅读(234) 评论(0) 推荐(0) 编辑
摘要:栈实际应用现场:先入后出(顺序栈)#include "linkedlist.h"#include <stdlib.h>#include <stdio.h>#ifdef DMALLOC#include "dmalloc.h"#endiftypedef struct { LinkedList *list;} StackStack *stack_construct() { Stack *stack = NULL; stack = calloc(1, sizeof(Stack));if (stack == NULL) { return N 阅读全文
posted @ 2011-09-27 12:50 火腿骑士 阅读(208) 评论(0) 推荐(0) 编辑
摘要:#include "logger.h"#include <stdio.h>#include <sys/types.h>#include <time.h>#include <ctype.h>#include <sys/time.h>#include <time.h>#include <stdlib.h>#include <string.h>#define tAGO 257#define tDAY 258#define tDAY_UNIT 259#define tDAYZONE 26 阅读全文
posted @ 2011-09-27 12:47 火腿骑士 阅读(466) 评论(0) 推荐(0) 编辑
摘要:#include <time.h>#include "date.h"#include "gettimestamp.h"#include "logger.h"#include <time.h>#include <locale.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#ifdef DMALLOC#include "dmalloc.h"#endiftypedef struct 阅读全文
posted @ 2011-09-27 12:42 火腿骑士 阅读(338) 评论(0) 推荐(0) 编辑
摘要:队列实际应用现场:先入先出#include "queue.h"#include "linkedlist.h"#include <stdlib.h>#include <stdio.h>#ifdef DMALLOC#include "dmalloc.h"#endiftypedef struct { LinkedList *list;} Queue;Queue *queue_construct() { Queue *queue = NULL; /* * Allocate space for the object an 阅读全文
posted @ 2011-09-27 12:39 火腿骑士 阅读(369) 评论(2) 推荐(0) 编辑
摘要:#ifndef FILE_H#define FILE_H#include "descriptor.h"#include "date.h"#include "dictionary.h"#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/time.h>#include <sys/types.h>#include <time.h>#include <unistd.h& 阅读全文
posted @ 2011-09-27 11:56 火腿骑士 阅读(218) 评论(0) 推荐(0) 编辑
摘要:#ifndef LINKED_LIST_H#define LINKED_LIST_Htypedef struct LinkedListNode { const void *data; struct LinkedListNode *prev; struct LinkedListNode *next;} LinkedListNode; typedef struct { LinkedListNode *head; LinkedListNode *current; LinkedListNode *tail; int size;} LinkedList;#define... 阅读全文
posted @ 2011-09-27 11:54 火腿骑士 阅读(233) 评论(0) 推荐(0) 编辑
摘要:#include <string.h>#include <stdlib.h>typedef struct LinkedList { char *s; struct LinkedList *next;} LinkedList;void freell(LinkedList *list){ LinkedList *cur = list; if(list == NULL) return; freell(list->next); free(list->s); free(list);}LinkedList *createll(char *s){ LinkedList * 阅读全文
posted @ 2011-09-27 11:45 火腿骑士 阅读(223) 评论(0) 推荐(0) 编辑
摘要:typedef struct _list { struct _list* plPrev; struct _list* plNext; void* p;} list;int ListCreate( list *pl ) { pl->plPrev = pl->plNext = pl; pl->p = NULL; return 0;}list *ListInsert( list *pl, void *p ) { list *plNew; if ( (plNew = (list*)malloc( sizeof( *plNew ))) == NULL )return NULL; plN 阅读全文
posted @ 2011-09-27 10:22 火腿骑士 阅读(250) 评论(0) 推荐(0) 编辑
摘要:#ifdef HAVE_CONFIG_H# include <config.h>#endif#include <errno.h>#include <stdlib.h>#include <string.h>#include <list0.h>#include <iterator0.h>#include <mailutils/errno.h>intmu_list_create (mu_list_t *plist){ mu_list_t list; int status; if (plist == NULL) ret 阅读全文
posted @ 2011-09-27 10:15 火腿骑士 阅读(278) 评论(0) 推荐(0) 编辑
摘要:if(window.attachEvent){window.attachEvent("onload",uf_attachFunction);alert("ie");}if(window.addEventListener){alert("ff");window.addEventListener("load",uf_attachFunction,false);}function uf_attachFunction(){ alert("test");}或if (document.all){window 阅读全文
posted @ 2011-09-26 18:00 火腿骑士 阅读(302) 评论(0) 推荐(1) 编辑
摘要:图1为线性表(ZHAO, QIAN, SUN, LI, ZHOU, WU, ZHENG, WANG)的逻辑状态。头指针 指示链表中第一个结点(即第一个数据元素的存储映像)的存储位置。同时,由于最后一个数据元素没有直接后继,则线性链表中最后一个结点的指针为“空”(NULL)。 图1 线性链表的逻辑状态 由上述描述可见,单链表可由头指针来唯一确定,在C语言中可用“结构指针”来描述。 view plaincopy to clipboardprint?//-----线性表的单链表存储结构----- typedefstructLNode{ElemTypedata;structLNode*next;... 阅读全文
posted @ 2011-09-26 13:09 火腿骑士 阅读(324) 评论(0) 推荐(0) 编辑
摘要:#include <stdlib.h>#include <stdio.h>#include <string.h>int del_char(char* src, char c){ if ( NULL == src) { fprintf(stderr, "del_char failed: invalid input./n"); return -1; } char* pchTemp = (char*)malloc(strlen(src) + 1); if ( NULL == pchTemp) { fprintf(stderr, "de 阅读全文
posted @ 2011-09-25 21:51 火腿骑士 阅读(918) 评论(0) 推荐(0) 编辑
摘要:- 链表的建立、插入和删除数组作为存放同类数据的集合,给我们在程序设计时带来很多的方便,增加了灵活性。但数组也同样存在一些弊病。如数组的大小在定义时要事先规定,不能在程序中进行调整,这样一来,在程序设计中针对不同问题有时需要3 0个大小的数组,有时需要5 0个数组的大小,难于统一。我们只能够根据可能的最大需求来定义数组,经常会造成一定存储空间的浪费。我们希望构造动态的数组,随时可以调整数组的大小,以满足不同问题的需要。链表就是我们需要的动态数组。它是在程序的执行过程中根据需要有数据存储就向系统要求申请存储空间,决不构成对存储区的浪费。链表是一种复杂的数据结构,其数据之间的相互关系使链表分成三种 阅读全文
posted @ 2011-09-25 14:44 火腿骑士 阅读(467) 评论(1) 推荐(0) 编辑
摘要:程序员们经常编写内存管理程序,往往提心吊胆。如果不想触雷,唯一的解决办法就是发现所有潜伏的地雷并且排除它们,躲是躲不了的。本文的内容比一般教科书的要深入得多,读者需细心阅读,做到真正地通晓内存管理。 1、内存分配方式 内存分配方式有三种: (1)从静态存储区域分配。内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在。例如全局变量,static变量。 (2)在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集中,效率很高,但是分配的内存容量有限。 (3) 从堆上分配,亦称动态内... 阅读全文
posted @ 2011-09-25 11:09 火腿骑士 阅读(416) 评论(2) 推荐(0) 编辑
摘要:简介POSIX thread 简称为pthread,Posix线程是一个POSIX标准线程.该标准定义内部API创建和操纵线程.作用 线程库实行了POSIX线程标准通常称为pthreads.pthreads是最常用的POSIX系统如Linux和Unix,而微软Windowsimplementations同时存在.举例来说,pthreads-w32可支持MIDP的pthread Pthreads定义了一套 C程序语言类型、函数与常量,它以 pthread.h 头文件和一个线程库实现。 数据类型 pthread_t:线程句柄 pthread_attr_t:线程属性 线程操纵函数(简介起见,... 阅读全文
posted @ 2011-09-19 11:31 火腿骑士 阅读(456) 评论(0) 推荐(0) 编辑
摘要:#include <stdlib.h>/*标准库函数*/#include <stdio.h>/*I/O函数*/#include <string.h>/*字符串函数*/#include <ctype.h>/*字符操作函数*/typedef struct bookinfo{int id;char name[20];int count;char nametype[20];//分类名称 char descript[50];//描述int country;//国家 }bookinfo;static bookinfo books;typedef struct 阅读全文
posted @ 2011-09-16 17:16 火腿骑士 阅读(320) 评论(0) 推荐(1) 编辑
摘要:char* buf = "安吉轻松2日游";int len;char * tmp = NULL;len = sizeof(char);//len=strlen(buf);strlen是指一个字符串的实际长度,从开始算到'\0'结束,而sizeof指一个数组定义的类型容量大小tmp = (char*)malloc(len);memset(tmp,0x00,len);//初始化指针内存 strcpy(tmp,buf);printf("tmp=%s\n",tmp);free(tmp);------------------------------ 阅读全文
posted @ 2011-09-13 17:04 火腿骑士 阅读(368) 评论(0) 推荐(0) 编辑
摘要:#include <malloc.h>#include <stdlib.h>#include <stdio.h>#include "queue.h"static resend_queue* head;static resend_queue* now;static resend_queue* tail;static resend_queue* temp;static resend_queue* del;static intqueue_num;static pthread_mutex_t lock_mute;bool queue_init() 阅读全文
posted @ 2011-09-13 11:25 火腿骑士 阅读(567) 评论(0) 推荐(0) 编辑
摘要:************************************************************************数据类型定义***********************************************************************/typedef unsigned long long D_UINT64;typedef unsigned long D_UINT32;typedef unsigned short D_UINT16;typedef unsigned char D_UINT8;typedefunsigned longD 阅读全文
posted @ 2011-09-05 11:17 火腿骑士 阅读(351) 评论(0) 推荐(1) 编辑
摘要:linux 下sqlite的 C编程之sqlite3_get_table说明:通过sqlite3_get_table查询得到的结果,其结构是:第一行是列名,随后的行才是值。遍历的方式和二维数组相同。#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <sqlite3.h>#include "test.h"int main(int argc, char **argv){ sqlite3 *db; char **dbResult; char *errms 阅读全文
posted @ 2011-09-03 14:38 火腿骑士 阅读(1137) 评论(0) 推荐(1) 编辑
摘要:最近遇到了解析配置的问题,用正规表达式感觉大题小做,使用sscanf因只会用基本用法,感觉功能不够,上网搜了下,解析起来不费吹灰之力,代码也很简洁。原帖出处不详,网上到处是,我做了点修改名称:sscanf() - 从一个字符串中读进与指定格式相符的数据.函数原型:Int sscanf( string str, string fmt, mixed var1, mixed var2 ... );int scanf( const char *format [,argument]... );说明:sscanf与scanf类似,都是用于输入的,只是后者以屏幕(stdin)为输入源,前者以固定字符串为输入 阅读全文
posted @ 2011-09-03 09:21 火腿骑士 阅读(464) 评论(0) 推荐(0) 编辑
摘要:#define UPGRADE_DEBUG 1#ifdef UPGRADE_DEBUG#define stb_printf(...) printf (__VA_ARGS__)//#define stb_printf(...) #else#define stb_printf(...) do { } while (0)#endif/************************************************************************ 常量定义********************************************************** 阅读全文
posted @ 2011-09-02 15:25 火腿骑士 阅读(420) 评论(0) 推荐(0) 编辑
摘要:/*********头文件区****************************************************/#include "dare_program.h"//#include "dare_sntp.h"//#include "input_event.h"#include "ipanel_event.h"#include "stb_debug_ctrl.h"#ifdef STBSW_DEBUG_dare_program#define stb_printf(...) S 阅读全文
posted @ 2011-09-02 15:15 火腿骑士 阅读(341) 评论(0) 推荐(0) 编辑
摘要:http://www.cnblogs.com/livexy/archive/2010/07/06/1772213.htmlusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Reflection;using System.Data;using System.Data.Common;using System.Web.Script.Serialization;using System.IO;using System.Security.Cryptography;n 阅读全文
posted @ 2011-09-02 14:54 火腿骑士 阅读(276) 评论(0) 推荐(0) 编辑
摘要:IList<MediaInfo> l = new List<MediaInfo>(); l.OrderByDescending(m => m.Name);//降序 Dictionary<int, string> dList = new Dictionary<int, string>(); List<KeyValuePair<int, string>> list = dList.OrderByDescending(k => k.Value).ToList();//降序 阅读全文
posted @ 2011-09-02 14:50 火腿骑士 阅读(591) 评论(0) 推荐(0) 编辑
摘要:1,防止一个头文件被重复包含 #ifndef COMDEF_H #define COMDEF_H //头文件内容 #endif 2,重新定义一些类型,防止由于各种平台和编译器的不同,而产生的类型字节数差异,方便移植。 typedef unsigned char boolean; /* Boolean type. */ typedef unsigned long int uint32; /* Unsigned 32 bit */ typedef unsigned short uint16; /* Unsigned 16 bit */ typedef unsigned char uint8; /* 阅读全文
posted @ 2011-09-02 13:49 火腿骑士 阅读(252) 评论(0) 推荐(1) 编辑

点击右上角即可分享
微信分享提示