مرحباً شباب :lol:
انا كاتب برنامج إلي هو push & pop إلي نستخدمه في الـ stack memory
لكن استخدمت معاه الـ node
وأصبح عندي أخطأ وأحتاج إلى حل :mellow:
هذا هو الكود
#include <stdio.h>
#include <stdlib.h>
typedef int stackentry;
typedef stract node
{
stackentry item;
stack node *next;
} node ;
typedef strack stack { node *top; } stack;
void creatstack (stack *S);
void push (stack *s,stackentry entry);
void pop (stack *s,stackentry *entry);
int stackempty (stack *s)
main ()
stack s;
stack item;
int choise;
creat stack (&s);
DO
{
printf("ERROR\n 1.for push\n" "2.pop\n" "3.exit\n");
scanf("%d",&choise);
switch(choise)
{
case1:
{
printf("Enter on element\n");
scanf("%d",&item);
push(&s,item)
break;
}
case2:
{
pop(&s,item)
printf("The element is %d; item);
break;
}
}
while(shoise!=3);
return 0;
}
void creat stack(stack *s)
{
s->top=null;
}
void push (stack *s,stackentry entry)
{
node *np
np=(node*)malloc(sizeof(node));
if (np==null)
print("ERROR,these is not space vailable\n");
else
if (s->top==null)
{
s->top=np;
np->next=null;
np->item=entry;
}
else {
np->next=s->top;
s->top=np;
np->item=entry;
}
}
void pop (stack *s,stackentry *entry)
{
if (stackempty(s))
{
printf("ERROR,stack is empty\n");
else
{node *np=s->top;
*entry=np->item;
s->top=s->top->next;
free(np)
}
}
int stack empty (stack *s)
{
return s->top==null;
}وأتمنى انكم تعلموني ليش حصلت هالأخطاء
شاكراً لكم
:happy: