当前位置: 技术问答>linux和unix
请教高手关于头文件的问题 !
来源: 互联网 发布时间:2016-02-16
本文导语: 在Linux 下 编辑五个文件然后用 gcc reword.c squeue.c sstack.c sstack.h squeue.h 命令进行编译连接怎么老是不行阿??。 出错信息如下:In file included from reword.c:4: 1:REWORD.C文件内容: #include #include //typedef char DataT...
在Linux 下 编辑五个文件然后用 gcc reword.c squeue.c sstack.c sstack.h squeue.h 命令进行编译连接怎么老是不行阿??。
出错信息如下:In file included from reword.c:4:
1:REWORD.C文件内容:
#include
#include
//typedef char DataType ;
#include"sstack.h"
#include"squeue.h"
#define MAXSIZE 50
int strlen(char *str)
{int i;
for(i=0;str[i]!='';i++);
return i;
}
int main(void)//rewordtest
{ char str[MAXSIZE];
printf("please input your words:n");
scanf("%s",str);
int len=strlen(str);
int i;
char tempx,tempy;
stack *ps;lqueue *pl;
if((ps=(stack*)malloc(sizeof(stack)))==0)printf("failedn");
if((pl=(lqueue*)malloc(sizeof(lqueue)))==0)printf("failedn");
intialstack(ps);intialqueue(pl);
for(i=0;itop==MAXSIZE-1)printf("stack is full can not insertn");
else {ps->list[(ps->top)+1]=x;
ps->top++;}
return 1;
}
int gettop(stack *ps ,DataType *x)
{ if(ps->toplist[ps->top];ps->top--;}
return 1;
}
3:SSTACK。H文件内容:#ifndef SSTACK_H
#define SSTACK_H
typedef char DataType ;
typedef struct
{ DataType list[MAXSIZE];
int top;
}stack;
extern int intialstack(stack *ps);
extern int sinertnode(stack *ps,DataType x);
extern int gettop(stack *ps ,DataType *x);
#endif
4:SQUEUE。H文件内容:#ifndef SQUEUE_H
#define SQUEUE_H
typedef char DataType ;
typedef struct
{ DataType list[MAXSIZE];
int front;
int rear;
}lqueue;
extern int intialqueue(lqueue *pl) ;
extern int insertqueue(lqueue *pl,DataType x) ;
extern int outqueue(lqueue *pl , DataType *x);
#endif
5:SQUUE.C文件内容:#include"squeue.h"
#include
int intialqueue(lqueue *pl) //intial
{ pl->front=0;
pl->rear=0;
return 1;
}
int insertqueue(lqueue *pl,DataType x) //insert
{ if((pl->rear+1)%MAXSIZE==pl->front){printf("queue is full !n");return 0;}
else
{ pl->list[pl->rear]=x;
pl->rear=(pl->rear+1)%MAXSIZE;return 1;}
}
int outqueue(lqueue *pl , DataType *x)
{ if(pl->front==pl->rear){printf("the queue is empty!n");return 0;}
else {
*x=pl->list[pl->front];
pl->front=(pl->front+1)%MAXSIZE;return 1;}
}
各位大侠看一下是什么问题阿?
谢谢
出错信息如下:In file included from reword.c:4:
1:REWORD.C文件内容:
#include
#include
//typedef char DataType ;
#include"sstack.h"
#include"squeue.h"
#define MAXSIZE 50
int strlen(char *str)
{int i;
for(i=0;str[i]!='';i++);
return i;
}
int main(void)//rewordtest
{ char str[MAXSIZE];
printf("please input your words:n");
scanf("%s",str);
int len=strlen(str);
int i;
char tempx,tempy;
stack *ps;lqueue *pl;
if((ps=(stack*)malloc(sizeof(stack)))==0)printf("failedn");
if((pl=(lqueue*)malloc(sizeof(lqueue)))==0)printf("failedn");
intialstack(ps);intialqueue(pl);
for(i=0;itop==MAXSIZE-1)printf("stack is full can not insertn");
else {ps->list[(ps->top)+1]=x;
ps->top++;}
return 1;
}
int gettop(stack *ps ,DataType *x)
{ if(ps->toplist[ps->top];ps->top--;}
return 1;
}
3:SSTACK。H文件内容:#ifndef SSTACK_H
#define SSTACK_H
typedef char DataType ;
typedef struct
{ DataType list[MAXSIZE];
int top;
}stack;
extern int intialstack(stack *ps);
extern int sinertnode(stack *ps,DataType x);
extern int gettop(stack *ps ,DataType *x);
#endif
4:SQUEUE。H文件内容:#ifndef SQUEUE_H
#define SQUEUE_H
typedef char DataType ;
typedef struct
{ DataType list[MAXSIZE];
int front;
int rear;
}lqueue;
extern int intialqueue(lqueue *pl) ;
extern int insertqueue(lqueue *pl,DataType x) ;
extern int outqueue(lqueue *pl , DataType *x);
#endif
5:SQUUE.C文件内容:#include"squeue.h"
#include
int intialqueue(lqueue *pl) //intial
{ pl->front=0;
pl->rear=0;
return 1;
}
int insertqueue(lqueue *pl,DataType x) //insert
{ if((pl->rear+1)%MAXSIZE==pl->front){printf("queue is full !n");return 0;}
else
{ pl->list[pl->rear]=x;
pl->rear=(pl->rear+1)%MAXSIZE;return 1;}
}
int outqueue(lqueue *pl , DataType *x)
{ if(pl->front==pl->rear){printf("the queue is empty!n");return 0;}
else {
*x=pl->list[pl->front];
pl->front=(pl->front+1)%MAXSIZE;return 1;}
}
各位大侠看一下是什么问题阿?
谢谢
|
gcc reword.c squeue.c sstack.c sstack.h squeue.h
应该是
gcc reword.c squeue.c sstack.c
或是一个个来,
gcc -c reword.c
gcc -c squeue.c
gcc -c sstack.c
gcc reword.o squeue.o sstack.o
应该是
gcc reword.c squeue.c sstack.c
或是一个个来,
gcc -c reword.c
gcc -c squeue.c
gcc -c sstack.c
gcc reword.o squeue.o sstack.o
|
楼上正解,你编译的时候,不用加头文件.
|
在编译的时候不用加都文件,因为头文件在预编译的时候已经加上去了