Hello everyone. I am just started learning c++. In the code here, I try to print the stack, but getting a segmenmentation fault. Any help appreciated, thanks in advance.
Check the for loops. The increment/decrement and the condition to stop the loop seem to have been reversed. If the code ends up going beyond the bounds of the items array into memory it shouldn't access, that might cause a segmentation fault.
The for loop is designed to iterate a number of times. Its syntax is:
for (initialization; condition; increase) statement;
Thank you guys, now it is in this form.
It prints now., with a slight problem. For example, it should print "4", but it prints "40x544645".
What do you guys think the problem is?