Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6788253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:27:49+00:00 2026-05-26T17:27:49+00:00

I had to build a C program which convert’s infix notation into postfix notation

  • 0

I had to build a C program which convert’s infix notation into postfix notation using STACK. That went well and it’s working in some way. It was long ago when I used last time C language so I’m probably dont use char[] variables very well.

So problem is that when I give input like this :

A+B*(C*E-D)

My program returns this :

ABCE*D-*+ĚĚĚĚĚĚĚĚĚĚĚ

So as you see my program did postfix conversion very well but I have bunch of “garbage” chars at my result (ĚĚĚĚĚĚĚĚĚĚĚ).

Here is snippet of my code (only part that I think is not correct, maybe something with char[] and way how I assing value to postfix[] variable:

int main()
{
    char infix[20], postfix[20];
    int len, tip, i, p=0;

    STACK pom;
    MAKE_NULL(&pom);

    printf ("Unesi izraz.\n");
    scanf ("%s", infix);

    len = strlen(infix);

    for(i=0; i<len; i++)
    {
        tip = nadi_tip(infix[i]);

        if (tip == Lijeva)
        {
            PUSH (infix[i], &pom);
        }

        if (tip == Operand)
        {
            postfix[p] = infix[i];
            p++;
        }

        if (tip == Desna)
        {
            while (!EMPTY(pom) && (TOP(pom)!= '('))
              {
                postfix[p++] = TOP(pom);
                POP (&pom);
              }
            POP (&pom);
        }

        if (tip == Operator)
        {
            while (!EMPTY(pom) && TOP(pom)!= '(')
             {
                if(prioritet(infix[i]) <= prioritet(TOP(pom)))
                {
                  postfix[p++] = TOP(pom);
                  POP (&pom);
                }
                else break;
             }
             PUSH(infix[i], &pom);
        }
    }
 while (EMPTY(pom) != 1)
 {
    postfix[p++] = TOP(pom);
    POP(&pom);
 }

 printf("Izlaz: %s", postfix);
 return 0;

}

infix[] is my input and postfix[] is my output. What did I do wrong I why am I having ĚĚĚĚĚĚĚĚĚĚĚ characters. Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:27:50+00:00Added an answer on May 26, 2026 at 5:27 pm

    It looks like you don’t have a NUL terminator on your postfix string. You could either change the definition to char postfix[20] = {0};, or you just before the printf, you could add postfix[p] = '\0';

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a program running for 2 days to build a Lucene index for
I was wondering if anyone knew whether Visual Studio .NET had a parallel build
I had been asked to build crystal reports for an application, i used the
I had never tried Continuum as a build server until recently when a project
Has anybody had any success getting Team Build to show xUnit.net test results and
So just this week I had the opportunity to re-build my development machine and
I've never used an automated build system - to be honest, I've never had
A job came in to me that's built with CodeCharge - had a look
I've written a C++ DLL that connects to a Sybase database using the native
I'm building a program in WPF which must feature multi-language support, with the ability

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.