首页 新闻 会员 周边

C语言编程,编译没有问题,运行有问题

0
悬赏园豆:15 [已关闭问题] 关闭于 2017-09-17 17:28

我将所有的部分分开,以下是两个头文件

c1.h

//数据存储结构。
#include<string.h>
#include<ctype.h>
#include<malloc.h>
#include<stdio.h>
#include<limits.h>
#include<stdlib.h>
#include<io.h>
#include<math.h>
#include<sys/timeb.h>
#include<stdarg.h>

//函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0

typedef int Status;
typedef int Boolean;

 

 

c1-1.h

typedef ElemType*Triplet;

 

----------------------------------------------------

然后是操作函数

bo1-1.cpp

//基本操作函数

Status InitTriplet(Triplet &T,ElemType v1,ElemType v2,ElemType v3)
{
T=(ElemType*)malloc(3*sizeof(ElemType));
if(!T)
exit(OVERFLOW);
T[0]=v1,T[1]=v2,T[2]=v3;
return OK;

}

 

func1-1.cpp

/不是基本操作,但是会被多次调用的函数或者是程序段


void PrintE(ElemType e)
{
printf("%d\n",e);
}

void PrintT(Triplet T)
{
printf("%d,%d,%d",T[0],T[1],T[2]);
}

 

 

最后是主函数

main1-1.cpp

//调用基本操作的主程序
#include"c1.h"
typedef int ElemType;
#include"c1-1.h"
#include"bo1-1.cpp"
#include"func1-1.cpp"
void main()
{
Triplet T;
ElemType m;
Status i;
i=InitTriplet(T,5,7,9);
printf("调用初始化函数后,i=%d(1:成功)。T的3个值是",i);
PrintT(T);

}

 

----------------------------------报错信息--------------------

o1-1.cpp
E:\data_structure\one\1\bo1-1.cpp(6) : error C2146: syntax error : missing ';' before identifier 'InitTriplet'
E:\data_structure\one\1\bo1-1.cpp(6) : error C2501: 'Status' : missing storage-class or type specifiers
E:\data_structure\one\1\bo1-1.cpp(6) : fatal error C1004: unexpected end of file found
func1-1.cpp
E:\data_structure\one\1\func1-1.cpp(4) : error C2065: 'ElemType' : undeclared identifier
E:\data_structure\one\1\func1-1.cpp(4) : error C2146: syntax error : missing ')' before identifier 'e'
E:\data_structure\one\1\func1-1.cpp(4) : error C2182: 'PrintE' : illegal use of type 'void'
E:\data_structure\one\1\func1-1.cpp(4) : error C2059: syntax error : ')'
E:\data_structure\one\1\func1-1.cpp(5) : error C2143: syntax error : missing ';' before '{'
E:\data_structure\one\1\func1-1.cpp(5) : error C2447: missing function header (old-style formal list?)
E:\data_structure\one\1\func1-1.cpp(9) : error C2065: 'Triplet' : undeclared identifier
E:\data_structure\one\1\func1-1.cpp(9) : error C2146: syntax error : missing ')' before identifier 'T'
E:\data_structure\one\1\func1-1.cpp(9) : error C2182: 'PrintT' : illegal use of type 'void'
E:\data_structure\one\1\func1-1.cpp(9) : error C2059: syntax error : ')'
E:\data_structure\one\1\func1-1.cpp(10) : error C2143: syntax error : missing ';' before '{'
E:\data_structure\one\1\func1-1.cpp(10) : error C2447: missing function header (old-style formal list?)
取个名不容易的主页 取个名不容易 | 菜鸟二级 | 园豆:210
提问于:2017-09-17 17:06
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册