Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

Implementation:

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
Comments
pasztorpisti 12-Nov-12 4:13am    
A converter that handles braces too: http://geekswithblogs.net/venknar/archive/2010/07/09/algorithm-for-infix-to-postfix.aspx
Its C# but you should be able to rewrite it.

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.
 
Share this answer
 
Comments
Aftab Gikian 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.
Aftab Gikian 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.
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"[^].
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900