Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save whalehulk/ae157ad6ceff208243eb2ce7dbcf513a to your computer and use it in GitHub Desktop.
Save whalehulk/ae157ad6ceff208243eb2ce7dbcf513a to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<ctype.h>
//our task is to convert infix to postfix expression using stack
//first we need a stack
//let's define it
char s[max];
int val; //here val is value to be pushed to the stack
//define a top pointer for stack
int top=-1;
//defining a string array for storing the entered infix string
char exp[100];
//defining functions
//this functions may be required
// basic stack functions
void push(void);
void pop(void);
//start main function of the program
int main()
{
printf("Enter any postfix expression:\n");
gets(exp);
val=evaluateposfix(exp);
return 0;
}
//infixtopostfix() function
void infixtopostfix(void)
{
/*
START FROM HERE GUYS :)
*/
}
void push(void)
{
//for pushing or inserting an element we check overflow condition
if(x==max-1)
{
printf("Error : Stack Overflow\n");
}
//incrementing the pointer
top++;
//finally pushing or inserting the value in stack.
s[top]=x;
}
void pop(void)
{
//for pop function we first check underflow conditions
if(top==max-1)
{
printf("Error : Stack Under Flow");
}
//decrementing the top pointer for deletion of element
top--;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment