I need help with the output please. The program is good when entering the seven numbers but it dont output any number when entering the number seven number into a stack. The code below and thank you for taking your time to look at the code.
first of all this code is a fuckin mess.
please put the functions above the main and make some new line between functions.
it is just so much easier if main is always the last function and you can see where something starts or ends.
also dont change your counting index (top in your case), before you have actually changed the variable.
your emptystack() function is returning 1 if the stack is empty, but your while statement in line 25 only pops and prints stuff if emptystack returns 1.
Calling the pop function st.pop();
Sorry for the messing code, is the error in the while loop if so can you give me a example please?
I thought the error is within the output section of the code within the while loop?
would the conditions have to been while (!st.emptystack()) or no?
Thank for your help!
Clearly it hits every-other one,
the val top, is pointing to every-other value and this can be seen by placing ChkFlgs in each subrt'n .
top = 2, top = 4, top=6
( actually a much better name for this val would be somethine like:
int i_stk_pntr, or i_stackPointer as it describes both it's function and it''s type.
btw, why all of this code? First you subtract 1 then you add 1 ??
1 2 3 4
int Stack::pop()
{
top--;
return number[top +1];
So that it's ONLY function is to return what it already had. e.g. it's useless.
@Incis B Thank you very much I got it working. Thank you to very one here who left a comment to help. I am grateful for your time and help thank you very much. Incis B it was a easy mistake to fix thanks for the help Lool!!!