64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
#define TURE 1
#define FALSE 0
#define ERROR 0
#define OK 1
#define INFEASIBLE -1
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef struct
{
char * elem;
int length;
int listsize;
}SqList;
int Initlist_Sq(SqList &L)
{
L.elem=(char *)malloc(LIST_INIT_SIZE*sizeof(char));
if(!L.elem)
exit(INFEASIBLE);
L.length =0;
L.listsize=LIST_INIT_SIZE;
return OK;
}
int main(void)
{
SqList L1;
Initlist_Sq(L1);
return 0;
}
为什么这么喜欢宏定义?#include <iostream>
using namespace std;
#define TURE 1
#define FALSE 0
#define ERROR 0
#define OK 1
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
#define LIST_INTT_SIZE 100
#define LISTINCREMENT 10
typedef struct {
char * elem;
int length;
int listsize;
}SqList;
Status Initlist_Sq(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 ()
{
SqList L1;
Initlist_Sq(L1);
return 0;
}