zizi21
asked on
Stack :Urgent...
Hi ,
I am having some problems with stacks. I am debugging it.
Is this the way to create stacks?
typedef struct numbers{
int num1;
int num2;
}NUM;
typedef struct stack
{
NUM *rows;
int n;
int topofstack;
}STA;
in create function..
s->n=10;
s->topofstack=0;
s->rows=malloc(s->n*sizeof (NUM *));
in push function..
s->topofstack+=1;
s->rows[s->topofstack].num 1=0;
s->rows[s->topofstack].num 2=10
this is where i think the problem is ...
in the create function, i have malloced an array of pointers...
now here, do i malloc for an item ?or this is fine?
I am having some problems with stacks. I am debugging it.
Is this the way to create stacks?
typedef struct numbers{
int num1;
int num2;
}NUM;
typedef struct stack
{
NUM *rows;
int n;
int topofstack;
}STA;
in create function..
s->n=10;
s->topofstack=0;
s->rows=malloc(s->n*sizeof
in push function..
s->topofstack+=1;
s->rows[s->topofstack].num
s->rows[s->topofstack].num
this is where i think the problem is ...
in the create function, i have malloced an array of pointers...
now here, do i malloc for an item ?or this is fine?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you.
ASKER