Hi. . can any one help me in converting infix to postfix. . i do not know what is wrong in my code. . help!!!plz

#include<iostream>
#include<string>
#include<conio.h>
#include<stdio.h>
using namespace std;
void main()
{
 char stack[10];
 char input[10];
 char output[10];
 char plusminus,multdiv;
 int a;
 cout<<"\tInput an infix expression:";
 gets(input);
int i;
i=strlen(input);
cout<<strlen(input);
for(a=0;a<=i;a++){
  if(input[a]>='a'&&input[a]<='z'){
   
   output[a]=input[a];
  }
  else if(input[a]=='+'||input[a]=='-'){
   plusminus=input[a];
  }
  else if(input[a]=='*'||input[a]=='/'){
   multdiv=input[a];
  }
  if(input[a]==plusminus){
   stack[a]=input[a];
   if(stack[a]==plusminus&&stack[a+1]==plusminus){
    output[a]=stack[a];
   }
  }
  else if(input[a]==multdiv){
   stack[a]=input[a];
   if(stack[a]==multdiv&&stack[a+1]==multdiv){
    output[a]=stack[a];
   }
  } 
 }
  cout<<"\tPostfix Expression :"<<output<<"\n"; 
}

First of all add code tags. Find out why void main and gets are bad. There is many posts about them.

Hi. . can any one help me in converting infix to postfix. . i do not know what is wrong in my code. . help!!!plz

Neither do we, you didn't tell us what it's doing wrong, nor what it does right. We need information to understand the problem.

And check the following links to see what is wrong with gets() and void main()

Friends plz help me to write simple c++ program just to convert infix expression to postfix expression using stacks, i don't know abt C++ too much, just write a simple c++ program, i have to submit my assignment, mail me at: SNIP

Edited 7 Years Ago by happygeek: email snipped

Comments
Double poster: http://www.daniweb.com/forums/thread231392.html
This article has been dead for over six months. Start a new discussion instead.