Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C
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 11-Nov-12 22:03pm
Comments
pasztorpisti at 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.
Rate this: bad
good
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.
  Permalink  
Comments
Member 9505466 at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 12-Nov-12 13:10pm
   
ok fine and thanks a lot !
:-(
Rate this: bad
good
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"[^].
  Permalink  
Comments
nv3 at 12-Nov-12 8:56am
   
Great link for people who want to understand compiler technology!
Richard MacCutchan at 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
0 CPallini 330
1 Sergey Alexandrovich Kryukov 313
2 George Jonsson 291
3 Prasad Avunoori 155
4 OriginalGriff 149
0 OriginalGriff 4,623
1 CPallini 3,410
2 Sergey Alexandrovich Kryukov 2,929
3 George Jonsson 2,319
4 Gihan Liyanage 2,077


Advertise | Privacy | Mobile
Web03 | 2.8.140905.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2014
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