用C++写的一个创建顺序表,并且初始化一个顺序表的程序,为什么编译不通过?求大神帮忙看看问题出哪了.

南人旧梦_ 2013-09-19 11:13:45
#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;

}

...全文
236 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ken_scott 2013-09-20
  • 打赏
  • 举报
回复
(Sqlist &L) // 大小写。。。 LIST_INIT_SIZE // #define LIST_INTT_SIZE 100 名字又错了 #include <cstdlib> // 缺少头文件 return OK; } // 这一块代码中可能还有全角下的字符 楼主太不细心了,不应该
ztenv 版主 2013-09-20
  • 打赏
  • 举报
回复
编译器应该有明确提示的,
猫仔- 2013-09-20
  • 打赏
  • 举报
回复
#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;
 
}
为什么这么喜欢宏定义?
turing-complete 2013-09-19
  • 打赏
  • 举报
回复
别误会,我只是帮您重新贴一下代码。
#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;

}

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧