
14-04-2005, 17:51
|
|
|
|
חבר מתאריך: 27.07.03
הודעות: 146
|
|
|
צריך עזרה במחסנית בC (עם מצביעים/פוינטרים)
עשיתי מחסנית בC וזה לא עובד. הקומפילציה עובדת אבל התוכנית עצמה מתרסקת.
זה הקוד:
#define N 8
typedef struct soldiers
{
int type;
char color;
}soldiers;
soldiers sol[N][N],sol1[N][N];
struct move {
soldiers moves[N][N];
struct move *next;
};
struct move *top1=NULL;
struct move *create_move(soldiers a[N][N])
{
struct move *p;
p=(struct move *)malloc(sizeof(struct move));
copy_array(a,p->moves);
p->next=NULL;
return p;
}
//--------------------------
int is_empty_undo()
{
if(top1==NULL) return 1;
else return 0;
}
//--------------------------
void push_undo(soldiers a[N][N])
{
struct move *temp;
temp=create_move(a);
temp->next=top1;
top1=temp;
}
//--------------------------
void pop_undo(soldiers a[N][N])
{
struct move *temp;
temp=top1;
copy_array(temp->moves,a);
top1=temp->next;
free(temp);
}
אם למישהו יש רעיון מה לא בסדר זה יעזור....אני צריך תשובה עוד היום.....
|