What causes the smiley in the string output?
<p>This programs basically convertes infix to postfix. problem is, the <code>-</code> and <code>/</code> becomes smiley  face like this :)</p>

<p>Problem is, it displays different characters instead of the intended minus or division sign.</p>

<pre><code>// the program is used to convert a infix expression to a postfix expression



#include&lt;iostream&gt;
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
#include&lt;string.h&gt;
#include&lt;stdlib.h&gt;
#include&lt;string&gt;

using namespace std;


const int size =50;
char infix[size],postfix[size],stack[size];
int top=-1;

int precedence(char ch);   // function to get the precedence of the operator
char pop();  //function to pop an element from the stack
char topelement();  // returns the top element of the stack
void push(char ch);  // pushes an element into the stack



int main()
{
     char ele,elem,st[2];
     int prep,pre,popped,j=0,chk=0;
     char strr[50];
     cout&lt;&lt;"Enter infix notation : "&lt;&lt;endl;
     cin&gt;&gt;infix;
     strcpy(postfix," ");

     //gets(infix);

     for(int i=0;infix[i]!=0;i++)
          {
                  if(infix[i]!='('&amp;&amp;infix[i]!=')'&amp;&amp;infix[i]!='^'&amp;&amp;infix[i]!='*'&amp;&amp;infix[i]!='/'&amp;&amp;infix[i]!='+'&amp;&amp;infix[i]!='-')     
                       postfix[j++]=infix[i];
                  else if(infix[i]=='(')
                      {
                         elem=infix[i];
                         push(elem);
                      }
                  else if(infix[i]==')')
                      {
                         while(popped=pop() != '(')
                             postfix[j++]=popped;
                      }
                  else
                      {
                         elem=infix[i];
                         pre=precedence(elem);//stores the precedence of operator coming frm infix
                         ele=topelement();
                         prep=precedence(ele);//stores the precedence of operator at the top of the stack

                         if(pre &gt; prep)
                           push(elem);                                         

                         else
                           {
                                while(prep &gt;= pre)
                                  {
                                     if(ele=='#')
                                       break;
                                     popped=pop();
                                     ele=topelement();
                                     postfix[j++]=popped;
                                     prep=precedence(ele);
                                   }
                                   push(elem);
                            }
                         }
             } 

          while((popped=pop())!='#')
              postfix[j++]=popped;
          postfix[j]='\0';

          cout&lt;&lt;"\n post fix :"&lt;&lt;postfix&lt;&lt;endl;

           system("pause");
           return 0;
}

int precedence(char ch)
{
       switch(ch)
          {
               case '^' : return 5;
               case '/' : return 4;
               case '*' : return 4;                                            
               case '+' : return 3;
               case '-' : return 3;
               default  : return 0;
          }
}

char pop()                  //function to pop the element from the stack
{
     char ret;
     if(top!=-1)
       {  ret =stack[top];
          top--;
          return ret;
       }
     else
        return '#';
}

char topelement()          // function to return top element from the stack without popping
{     
      char ch;
      if(top!=-1)
        ch=stack[top];
      else
         ch='#';
       return ch;
}

void push(char ch)          // function to push an element in the stack
{
     if(top!=size-1)
         {
            top++;
            stack[top]= ch;
         }
}         
</code></pre>

<p><img src="http://i.stack.imgur.com/BhN0P.png" alt="enter image description here"></p>

<p>all <code>-</code> and <code>/</code> looks good in the code</p>
