tos=stack;
p1=stack;
stack points to more than one address at the same time i couldnt understand which one is for what ..
Assignments run right to left... more than one variable points to stack. They are initializing the stack array to an empty state.
secondly
do {
printf("ENTER VALUE");
scanf("%d",&value);
if(value!=0) push(value);
else printf("value on top %d",pop());
}while(value!=-1);
}
these values (0 and -1 )are indexses?? for example 0 means stack is empty -1 is full? or somethink like that
Nope... value comes from the keyboard via scanf() ... In the source editor, put your text cursor on the colourized keyword
scanf() and press F1 on your keyboard... you can read all about what it does from the help file (This works with any keyword or library function, btw.)
The main reason you're finding it so hard to follow is that it's poorly formatted...
do
{
printf("ENTER VALUE");
scanf("%d",&value);
if (value != 0)
push(value);
else
printf("value on top %d",pop());
}
while(value != -1);
See it now?
This is why source code is set up as it is... it's so you can follow the activity step by step. Jamming it all up into a couple of lines makes it's function much less clear.
Code setup ... commenting the non-obvious parts, even indenting with vertical and horizontal whitespaces make it much easier to follow. This is a good habit to get in right from the start. Ask yourself: "If I have to come back to this in a year, will I still be able to follow it?"
So ... reformat your code, all nice and tidy... then follow what's going on step by step... if you have any further questions, post them up and we'll see what we can do...