// Online C compiler to run C program online
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
struct Stack{
    int capacity;
    int top;
    char *items;
}s;
struct Stack *  createStack(int cap){
    struct Stack *s;
    s= (struct Stack *)malloc(sizeof(struct Stack));
    s->capacity = cap;
    s->items = (char *)malloc((cap) *sizeof(char));
    s->top=-1;
    return s;
}
void pop(struct Stack *s){
    if(s->top==-1){
        printf("\nStack is empty");
        return;
    }
    printf("%c",s->items[s->top]);
    s->top--;
}
void push(struct Stack *s,int ele){
    if(s->top == s->capacity-1){
        printf("Stack is full");
        return ;
    }
    s->top++;
    s->items[s->top]=ele;
}

int main() {
    char s[100],rev1[100],rev2[100];
    struct Stack *stack;
    printf("Enter String: ");
    fgets(s,sizeof(s),stdin);
    int len =strlen(s);
    stack = createStack(len);
    printf("Orignal string :%s",s);
    printf("Reversed using strrev : %s",s);
    int i=0;
    for(i=0;i<strlen(s)-1;i++){
        push(stack,s[i]);
    }
    printf("\nReversed Using stack: ");
    while(stack->top>=0){
        pop(stack);
    }

    return 0;
}