摘要: 前段时间用C写了一个程式,发现3年前学的C的基本语法都忘得差不多了。下面的格式化字符,我觉得值得我写个随笔,免得下次再写时,忘记了。格式字符控制:说明:sprintf(格式化后的字符,"%(长度)格式符",格式化前的字符);1、 d格式符。用来输出十进制数。有以下几种用法:(1)、%d按整数的实际长度输出。(2)、%md,m为指定的输出字段的宽度。如果数据位数小于m,则左端补以空格,若大于m,则按实际位数输出。(3)、%ld,输出长整型数据。例:long a=135790;printf(“%ld”,a);如果用%d输出就会发生错误,因为整型数据的范围是-32768到3276 阅读全文
posted @ 2011-10-12 14:18 火腿骑士 阅读(439) 评论(1) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <ctype.h>//结点类型typedef struct student{void *data;struct student* next;}student;//链表类型typedef struct studentlist{student* head;student* current;student* tail;int size;}studentlist;studentlist* linked_list_construct(){studentlist* list=NU 阅读全文
posted @ 2011-10-10 21:46 火腿骑士 阅读(227) 评论(0) 推荐(0) 编辑
摘要: argv: 指针的指针argc: 整数char **argv or char *argv[] or char argv[][]为了能形象的说明这两个参数的含义,我们先用一个实例来进行讲解:假设程序的名称为test,当只输入test,则由操作系统传来的参数为:argc = 1,表示只有一程序名称;argc只有一个元素,argv[0]指向输入的程序路径及名称:./ test当输入test para_1,有一个参数,则由操作系统传来的参数为:argc = 2,表示除了程序名外还有一个参数;argv[0]指向输入的程序路径及名称;argv[1]指向参数para_1字符串当输入test para_1 p 阅读全文
posted @ 2011-10-10 21:00 火腿骑士 阅读(302) 评论(0) 推荐(1) 编辑
摘要: (1)static 静态变量、静态函数。作用域只对本文件(xxx.c)有效,且静态函数声明不能出现在xxx.h头文件中上实战代码:/************************************************************************ 局部变量***********************************************************************/static D_TIMER_ID gui_tick_timer_id = -1;/******************************************* 阅读全文
posted @ 2011-10-10 11:23 火腿骑士 阅读(286) 评论(1) 推荐(0) 编辑
摘要: #include <stdlib.h>/*标准库函数*/#include <stdio.h>/*I/O函数*/#include <string.h>/*字符串函数*/#include <ctype.h>/*字符操作函数*/#include "linkedlist.h"#include "hashtable.h"#include "queue.h"typedef struct student{ int id; char name[15];} student; //节点定义//链表的遍历vo 阅读全文
posted @ 2011-10-09 11:10 火腿骑士 阅读(247) 评论(0) 推荐(0) 编辑
摘要: ________________________c_list.h__________________#ifndef C_LIST_H#define C_LIST_H#ifndef ERR#define ERR -1#define OK 1#endif#ifndef MAX#define MAX 100#define MIN 0#endiftypedef int status;typedef int type;typedef struct listitem { type date;//节点数据 struct listitem *next;//指向下个节点 } list_node;//链表节点ty 阅读全文
posted @ 2011-10-07 10:12 火腿骑士 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 开始结点:是指链表中的第一个结点,也就是没有直接前趋的那个结点。头指针:是一指向链表开始结点的指针(没有头结点时),单链表由头指针唯一确定,因此单链表可以用头指针的名字来命名。头结点:是在链表的开始结点之前附加的一个结点。有了头结点之后,头指针指向头结点,不论链表否为空,头指针总是非空。而且头指针的设置使得对链表的第一个位置上的操作与在表其他位置上的操作一致(都是在某一结点之后)。http://www.cnblogs.com/Jennifer/articles/2159484.htmlhttp://www.cnblogs.com/cpoint/archive/2010/12/20/191135 阅读全文
posted @ 2011-09-27 16:05 火腿骑士 阅读(408) 评论(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 火腿骑士 阅读(153) 评论(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 火腿骑士 阅读(3831) 评论(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 火腿骑士 阅读(428) 评论(0) 推荐(0) 编辑