#include <iostream>
using namespace std;
struct stack
{
int size;
int top;
int *arr;
};
int isEmpty(struct stack *ptr)
{
if (ptr->top == -1)
{
return 1;
}
else
{
return 0;
}
}
int isFull(struct stack *ptr)
{
if (ptr->top == ptr->size - 1)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
struct stack *s;
s->size = 80;
s->top = -1;
s->arr = (int *)malloc(s->size * sizeof(int));
// s->arr = new int[s->size];
//check if the stack is empty
if (isEmpty(s))
{
cout<<"The stack is empty";
}
else
{
cout << "The stack is not empty";
}
return 0;
}
Above is the code where I have not written endl under the if cout statement, but if I write it then I do not get the required output as:
"The stack is empty"