Click here to Skip to main content
13,355,018 members (59,810 online)
Rate this:
Please Sign up or sign in to vote.
See more:
The goal is to write an infix to postfix converter. Your program should be
able to handle addition, multiplication, subtraction and division operators in the input. It should also be able to handle (possibly nested) parentheses in the input expression.


The input to the program will a filename provided on the command line as follows.
c:> yourprog.exe file.txt
Each line in the file will be an expression in infix notation. Upon receiving the file name, you
should read each line from the file, convert each expression to postfix and output the converted
expression to screen.

meaning we have to write some expressions in the file and the read it and convert it into the postfix and output it,
Please atleast make a simple infix to postfix in c
Posted 11-Nov-12 23:03pm
pasztorpisti 12-Nov-12 4:13am
A converter that handles braces too:
Its C# but you should be able to rewrite it.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your program should be ...

That means you are expected to write it. We do not provide solutions to order, particularly for homework questions. Use your knowledge and course notes to write this for yourself. When you have specific problems then we will try to help you, but you are expected to do the main body of work.
Member 9505466 12-Nov-12 9:16am
I am totally agreed with you but the thing is unfortunately i have not enough time to read book and try, it takes too long to do it thats why i have to submit this latest by tommorow night and i am a undergraduate student i have many other assignments to do right now, kindly please help me out of this
I know the logic of this question but the thing is syntax, read from file etc
Please Please Please help me its is an absolute 5 marks !
Richard MacCutchan 12-Nov-12 10:14am
Like far too many students these days, you seem to think that you can waste time until the day before your assignment is due and then expect CodeProject members to write it for you. Sorry, but the answer is no.
CPallini 12-Nov-12 12:13pm
you haven't to read a whole book. For instance, the 'Dragon Book' shows exactly what you need in few pages.
Member 9505466 12-Nov-12 12:03pm
Ooof i am using the code project about a day ago and i am not asking you to give me the whole code but tell me the syntax and how to read files ?
Richard MacCutchan 12-Nov-12 12:12pm
I don't know how you can be one day away from completing your assignment and yet do not understand something as basic as file handling. Start with the CreateFile() function, and see connected pages for read, write and close. If you are planning to do this in pure C then I would suggest the C Run-Time Stream I/O functions.
Member 9505466 12-Nov-12 12:47pm
i meant to say the infix expression is already in file i have to read it and have to store somewhere i think i would store it in array and then convert it into postfix and again store the postfix expression to array and print the output at console screen am i right ?
Richard MacCutchan 12-Nov-12 12:52pm
Follow the first link that Carlo provided for you, and the first link from there explains exactly how to do it.
Member 9505466 12-Nov-12 13:10pm
ok fine and thanks a lot !
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You may find many many examples of infix to postfix converters just Googling for[^].
However, if you are really interested in the argument, then I suggest you reading a good book on compiler construction, like, for instance, the "Dragon Book"[^].
nv3 12-Nov-12 8:56am
Great link for people who want to understand compiler technology!
Richard MacCutchan 12-Nov-12 12:18pm
Great links, the top one can even be converted direct into code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180111.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100