//stack.h
struct stack{
int top;
char data[]; //set the size of this array
}s;
void init(){
s.top = -1;
}
int isFull(){
return (s.top==MAX-1) ? 1 : 0;
}
int isEmpty(){
return (s.top==-1) ? 1 : 0;
}
void push(char ch){
if(!isFull()){
s.data[++s.top] = ch;
}else{
printf("\n The stack is full\n");
}
}
char pop(){
return (!isEmpty()) ? s.data[s.top--] : '\0';
}
我想在头文件中实现此堆栈,并希望从外部设置数据数组的大小。我知道这是头文件,如果更改头变量,它没有用,但仍然很奇怪。 >
// stack.h struct stack {int top;字符数据[]; //设置此数组的大小} s; void init(){s.top = -1; } int isFull(){return(s.top == MAX-1)吗? 1:0; } int isEmpty(){...
您的结构包含所谓的柔性数组成员