创建两个栈来代替队的操作,没成功,哪里错了??

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
typedef struct stack
{
int* arr;
int size;
int top;
}stack;
//创建一个栈
void initstack(stack* s, int size)
{

s->arr = (int*)malloc(sizeof(size));
s->size = size;
s->top = -1;

}
//入栈
void push(stack* s, int size, int x)
{
if (s->top +1 == size)
{
printf("栈满,无法入栈");
exit(0);
}
else
{
s->top++;
s->arr[s->top] = x;
}
}
//出栈
void pop(stack *s, int size, int &x)
{
if (s->top == -1)
{
printf("栈空,无法出栈");
exit(0);
}
else
{
x = s->arr[s->top];
s->top = s->top--;
}
}
//获取栈顶元素
void Getstack(stack *s, int size, int& x)
{
if (s->top == -1)
{
printf("栈空,无法获取");
exit(0);
}
else
{
x = s->arr[s->top];
}
}
//入队操作
void EnSQueue(stack *S1, stack *S2, int size, int x)
{
if (S1->top + 1 != size)//先判S1是否为栈满,如果S1为不满,直接入队;
{
push(S1, size, x);
exit(1);
}
if (S1->top + 1 == size && S2->top != -1)//如果S1满了,S2也不为空,则队满
{
printf("队已满,无法入队");
exit(2);
}
if (S1->top + 1 == size && S2->top == -1)//如果S1满了,S2为空,S1全部出栈,S2入栈
{
while (S1->top != -1)
{
int y;
pop(S1, size, y);
push(S2, size, y);
}
push(S1, size, x);
}
}
//出队操作
void DeSQueue(stack *S1, stack *S2, int size, int &x)
{
if (S2->top != -1)//如果S2不为空就出栈
{
pop(S2, size, x);
}
else if (S1->top = -1)
{
printf("队空,无法出队");
}
else
{
while (S1->top != -1)
{
int y;
pop(S1, size, y);
push(S2, size, y);
}
pop(S2, size, x);
}
}
//队列判空
void SQueueEmpty(stack *S1, stack *S2)
{
if (S1->top == -1 && S2->top == -1)
{
printf("队空");
}
}

int main()
{ //创建两个个栈
stack *s1;
s1 = (stack )malloc(sizeof(stack));
stack
s2;
s2 = (stack *)malloc(sizeof(stack));
int size;
printf("请输入两个栈的大小:");
scanf("%d", &size);
initstack(s1, size);
initstack(s2, size);
EnSQueue(s1, s2, size, 5);
EnSQueue(s1, s2, size, 6);
EnSQueue(s1, s2, size, 8);
int x;
DeSQueue(s1, s2, size, x);
printf("出队的值:%d", x);

return 0;

}