數據結構 -03 順序存儲線性表實例2

條件編譯的目的;防止頭文件被重複包含。

#sqlist.h
#ifndef SQLIST_H__     //如果沒有包含SQLIST_H__,則下一條語句去定義宏名/宏體
#define SQLIST_H__    //此處define宏名SQLIST_H__,後面的所有內容爲宏體
 
#define DATASIZE 1024
 
typedef int datatype
 
typedef struct node_st
{
        datatype data[DATASIZE];
        int last;   //last here used as a counter.
};sqlist;
 
sqllist *sqlist_create();  //create linear table
 
void sqllist_create1(sqlist **); //return void if create failed
 
int sqlist_insert(sqlist *,int i,datatype *); // add data
 
int sqlist_delete(sqlist *,int i);
 
int sqlist_find(sqlist *,datatype *); //1st parameter "sqlist *" is current linktable, 2nd parameter is datatye
 
int sqlist_isempty(sqlist *);
 
int sqllist_setempty(sqlist *);
 
int sqlist_getnum(sqlist *);
 
int sqlist_union(sqlist *,sqlist *);
 
int sqlist_destroy(sqlist *); //return int if destroy succed
#endif
book@100ask:~/C_coding/CH03/arr$ make test1
cc     test1.c   -o test1
book@100ask:~/C_coding/CH03/arr$ ./test
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章