虽然我编译并即将推送元素我得到分段错误.什么是分段错误?任何人都可以向我解释这种类型的错误.它与内存处理有关吗?
#include<iostream>
#define MAX 10
using namespace std ;
typedef struct
{
int items[MAX] ;
int top=-1;
}node;
int isFull(node *s){
if (s->top==MAX-1)
{
return 1 ;
}
else{
return 0;
}
}
int isEmpty(node *s){
if (s->top==-1)
{
return 1 ;
}
else{
return 0;
}
}
void push(node *s , int );
void pop(node *s);
void push(node *s , int n ){
if (isFull(s))
{
cout<<"Stack overflow"<<endl;
}
else{
s->items[++(s->top)]=n;
}
}
void pop(node *s){
if(isEmpty(s)){
cout<<"The stack …Run Code Online (Sandbox Code Playgroud)