码迷,mamicode.com
首页 > 编程语言 > 详细

C语言表结构(1)

时间:2020-02-06 13:03:18      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:flow   inf   incr   exit   size   typedef   com   amp   str   

1、顺序表初始化实战:

#include<stdio.h>
#include<stdlib.h>
#define OK 1
#define OVERFLOW 0
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10

typedef struct
{
  char *elem;
  int length;  //当前长度
  int listsize;  //线性表的长度
}Sqlist;

/*线性表的初始化*/
int InitList(Sqlist *L)
{
  L->elem=(char*)malloc(LIST_INIT_SIZE*sizeof(char*));
  if(!L->elem)exit(OVERFLOW);
  L->length=0;
  L->listsize=LIST_INIT_SIZE;

 return OK;
}

int main()
{
  int i;
  Sqlist L;
  i=InitList(&L);
  printf("i=%d\n",i);

  return 0;
}

 技术图片

 

C语言表结构(1)

标签:flow   inf   incr   exit   size   typedef   com   amp   str   

原文地址:https://www.cnblogs.com/gufengchen/p/12268156.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!