快急疯了,求大家解决一个VC++编译问题,一天了也不知道为什么
好像是在c.h中定义的一些宏不起作用,为什么
错误提示:
Compiling...
aaa.cpp
ALGO2-1.CPP
BO2-1.CPP
d:\11\sfdf\bo2-1.cpp(3) : error C2146: syntax error : missing '; ' before identifier 'InitList '
d:\11\sfdf\bo2-1.cpp(3) : error C2501: 'Status ' : missing storage-class or type specifiers
d:\11\sfdf\bo2-1.cpp(3) : fatal error C1004: unexpected end of file found
StdAfx.cpp
Error executing cl.exe.
ggg.exe - 3 error(s), 0 warning(s)
//BO2-1.CPP的代码:
#include "stdafx.h "
Status InitList(SqList &L) // 算法2.3 /////指示此行出错
{ // 操作结果:构造一个空的顺序线性表
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem)
exit(OVERFLOW); // 存储分配失败
L.length=0; // 空表长度为0
L.listsize=LIST_INIT_SIZE; // 初始存储容量
return OK;
}
//主程序代码:
#include "c1.h " 在后
typedef int ElemType;
#include "c2-1.h " // 采用线性表的动态分配顺序存储结构
#include "bo2-1.cpp " // 可以使用bo2-1.cpp中的基本操作
Status equal(ElemType c1,ElemType c2)
{ // 判断是否相等的函数,Union()用到
if(c1==c2)
return TRUE;
else
return FALSE;
}
void Union(SqList &La,SqList Lb) // 算法2.1
{ // 将所有在线性表Lb中但不在La中的数据元素插入到La中
ElemType e;
int La_len,Lb_len;
int i;
La_len=ListLength(La); // 求线性表的长度
Lb_len=ListLength(Lb);
for(i=1;i <=Lb_len;i++)
{
GetElem(Lb,i,e); // 取Lb中第i个数据元素赋给e
if(!LocateElem(La,e,equal)) // La中不存在和e相同的元素,则插入之
ListInsert(La,++La_len,e);
}
}
void print(ElemType &c)
{
printf( "%d ",c);
}
void main()
{
SqList La,Lb;
Status i;
int j;
i=InitList(La);
if(i==1) // 创建空表La成功
for(j=1;j <=5;j++) // 在表La中插入5个元素
i=ListInsert(La,j,j);
printf( "La= "); // 输出表La的内容
ListTraverse(La,print);
InitList(Lb); // 也可不判断是否创建成功
for(j=1;j <=5;j++) // 在表Lb中插入5个元素
i=ListInsert(Lb,j,2*j);
printf( "Lb= "); // 输出表Lb的内容
ListTraverse(Lb,print);
Union(La,Lb);
printf( "new La= "); // 输出新表La的内容
ListTraverse(La,print);
}
//头文件c.h
// c1.h (程序名)
#include <string.h>
#include <ctype.h>
#include <malloc.h> // malloc()等
#include <limits.h> // INT_MAX等
#include <stdio.h> // EOF(=^Z或F6),NULL
#include <stdlib.h> // atoi()
#include <io.h> // eof()
#include <math.h> // floor(),ceil(),abs()
#include <process.h> // exit()
#include <iostream.h> // cout,cin
// 函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
// #define OVERFLOW -2 因为在math.h中已定义OVERFLOW的值为3,故去掉此行
typedef int ElemType;
typedef int Status; // Status是函数的类型,其值是函数结果状态代码,如OK等
typedef int Boolean; // Boolean是布尔类型,其值是TRUE或FALSE
[解决办法]
什么库啊,没看到链接错误是因为你写的函数,编译错误理论上自己要搞定的,好好检查语法!不用添加什么库啊什么的!改后的链接错误也是你函数定义或文件包含的问题!