
fatal error C1083: Cannot open include file: 'Stack.h': No such file or directory
源代码://头文件Stack.h#ifndef_Stack_hstructNode;typedefstructNode*PtrToNode;typedefPtrToNod...
源代码:
//头文件 Stack.h
#ifndef _Stack_h
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode Stack;
typedef int ElementType;
int IsEmpty(Stack S);
Stack CreateStack(void);
void DisposeStack(Stack S);
void MakeEmpty(Stack S);
void Push(ElementType X,Stack S);
ElementType Top(Stack S);
int Pop(Stack S);
#endif /*_Stack_h*/
//主文件 功能自己看函数名字~~见名知意
#include "Stack.h"
#include <stdio.h>
#include <stdlib.h>
struct Node
{
ElementType Element;
PtrToNode Next;
};
Stack CreateStack(void)
{
Stack S;
S=malloc(sizeof(struct Node));
if(S==NULL)
printf("出错啦");
S->Next=NULL;
MakeEmpty(S);
return S;
}
int IsEmpty(Stack S)
{
return S->Next==NULL;
}
void MakeEmpty(Stack S)
{
if(S==NULL)
printf("出错啦");
else
while(!IsEmpty(S))
Pop(S);
}
void Push(ElementType X,Stack S)
{
PtrToNode TmpCell;
TmpCell=malloc(sizeof(struct Node));
if(TmpCell==NULL)
printf("出错啦");
else
{
TmpCell->Element =X;
TmpCell->Next =S->Next ;
S->Next =TmpCell;
}
}
ElementType Top(Stack S)
{
if(!IsEmpty(S))
return S->Next ->Element;
printf("出错啦");
return 0;
}
int Pop(Stack S)
{
PtrToNode FirstCell;
int x=0;
if(IsEmpty(S))
printf("出错啦");
else
{
FirstCell=S->Next ;
x=FirstCell->Element ;
S->Next =S->Next ->Next ;
free(FirstCell);
}
return x;
}
void main()
{
int x;
Stack S,top;
S=CreateStack();
top=S;
Push(3,S);
Push(2,S);
Push(4,S);
//Pop(S);
S=top;
for(x=0;x<3;x++)
{
printf("%d\n",S->Next->Element);
S=S->Next ;
}
} 展开
//头文件 Stack.h
#ifndef _Stack_h
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode Stack;
typedef int ElementType;
int IsEmpty(Stack S);
Stack CreateStack(void);
void DisposeStack(Stack S);
void MakeEmpty(Stack S);
void Push(ElementType X,Stack S);
ElementType Top(Stack S);
int Pop(Stack S);
#endif /*_Stack_h*/
//主文件 功能自己看函数名字~~见名知意
#include "Stack.h"
#include <stdio.h>
#include <stdlib.h>
struct Node
{
ElementType Element;
PtrToNode Next;
};
Stack CreateStack(void)
{
Stack S;
S=malloc(sizeof(struct Node));
if(S==NULL)
printf("出错啦");
S->Next=NULL;
MakeEmpty(S);
return S;
}
int IsEmpty(Stack S)
{
return S->Next==NULL;
}
void MakeEmpty(Stack S)
{
if(S==NULL)
printf("出错啦");
else
while(!IsEmpty(S))
Pop(S);
}
void Push(ElementType X,Stack S)
{
PtrToNode TmpCell;
TmpCell=malloc(sizeof(struct Node));
if(TmpCell==NULL)
printf("出错啦");
else
{
TmpCell->Element =X;
TmpCell->Next =S->Next ;
S->Next =TmpCell;
}
}
ElementType Top(Stack S)
{
if(!IsEmpty(S))
return S->Next ->Element;
printf("出错啦");
return 0;
}
int Pop(Stack S)
{
PtrToNode FirstCell;
int x=0;
if(IsEmpty(S))
printf("出错啦");
else
{
FirstCell=S->Next ;
x=FirstCell->Element ;
S->Next =S->Next ->Next ;
free(FirstCell);
}
return x;
}
void main()
{
int x;
Stack S,top;
S=CreateStack();
top=S;
Push(3,S);
Push(2,S);
Push(4,S);
//Pop(S);
S=top;
for(x=0;x<3;x++)
{
printf("%d\n",S->Next->Element);
S=S->Next ;
}
} 展开
5个回答
展开全部
编译器没有找到Stack.h文件,有3个办法可以解决
1. 将Stack.h文件和你的主文件放在同一个文件夹里
2. 在 include 时指明 Stack.h 的相对路径。 比如你的Stack.h在上层目录的include文件夹下,那就写 #include "../include/Stack.h"
3. 在编译选项里面加上 Stack.h 文件的路径 -I ../include
另外,你的Stack.h文件少了一个define定义 。正确的格式是:
#ifndef _Stack_h
#define _Stack_h
...
... //这里是你的头文件实际代码
...
#endif
这样写才能保证你的Stack.h不会被重复包含。
1. 将Stack.h文件和你的主文件放在同一个文件夹里
2. 在 include 时指明 Stack.h 的相对路径。 比如你的Stack.h在上层目录的include文件夹下,那就写 #include "../include/Stack.h"
3. 在编译选项里面加上 Stack.h 文件的路径 -I ../include
另外,你的Stack.h文件少了一个define定义 。正确的格式是:
#ifndef _Stack_h
#define _Stack_h
...
... //这里是你的头文件实际代码
...
#endif
这样写才能保证你的Stack.h不会被重复包含。
2011-04-01
展开全部
使用的是 "<>" 尖括号的话,
表示让编译器在系统头文件夹中查找对应名字的头文件,
当使用""""引号时,就是让编译器在当前程序目录下查找对应名字的头文件,如果没有找到,则编译器会再在系统头文件夹中查找该头文件.
所以,这里,你应该把
#include <class.h>
改为
#include "class.h"
还有,
你上面的程序的写法是不标准的,(但是能通过许多编译器)
应该这么写
#include <iostream> // 注意,标准中,系统头文件不推荐加 .h,类似地有 <cmath> 而不是 <math.h>
#include "class.h"
using namespace std; // 使用标准的名空间
int main(int argc, char *argv[]) // 标准 C++中 必须显式的申明 main 的返回值类型,不写的话有些编译器默认是 int 型
{
float l, w, h;
...
...
..
p[i].OutPut();
}
return 0; // 记得返回值
}
另外,团IDC网上有许多产品团购,便宜有口碑
表示让编译器在系统头文件夹中查找对应名字的头文件,
当使用""""引号时,就是让编译器在当前程序目录下查找对应名字的头文件,如果没有找到,则编译器会再在系统头文件夹中查找该头文件.
所以,这里,你应该把
#include <class.h>
改为
#include "class.h"
还有,
你上面的程序的写法是不标准的,(但是能通过许多编译器)
应该这么写
#include <iostream> // 注意,标准中,系统头文件不推荐加 .h,类似地有 <cmath> 而不是 <math.h>
#include "class.h"
using namespace std; // 使用标准的名空间
int main(int argc, char *argv[]) // 标准 C++中 必须显式的申明 main 的返回值类型,不写的话有些编译器默认是 int 型
{
float l, w, h;
...
...
..
p[i].OutPut();
}
return 0; // 记得返回值
}
另外,团IDC网上有许多产品团购,便宜有口碑
展开全部
把主文件和Stack.h文件放在相同的目录下,然后include "Stack.h";应该就可以了
展开全部
把主文件和Stack.h文件放在相同的目录下面试试。然后到那个目录下面编译。
展开全部
#include <stdio.h>
#include <stdlib.h>
#include "Stack.h"
用这样的次序看看如何
#include <stdlib.h>
#include "Stack.h"
用这样的次序看看如何
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询