Thread: Postfix help!!

  1. #1
    Registered User
    Join Date
    Mar 2009

    Postfix help!!

    I want to make a stack based Postfix to infix converter. I don't know how to start with it. Presently I have a class of stack. Thats all.
    Can anybody help me with the algorithm.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    segmentation fault
    Have a quick look at the first example here, which is for parsing roman numerals (roman numerals are a form of prefixed notation), altho it is in C:


    This just uses a char array, but I suppose you could use a stack the same way. The key is using a "look ahead character" (x+1) in your evaluation of x:

    char *expr (char *ptr, int *value) {
    	char expr[128] = {0}, *s = ptr;
    	int a = trans(ptr[0]), b = trans(ptr[1]), dif;
    Obviously you must take care to insure that ptr[1] is not out of bounds, since this reads through the array one char at a time.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression: Convert infix notation to postfix notation.
    By Nutshell in forum C Programming
    Replies: 7
    Last Post: 02-27-2010, 07:44 AM
  2. Replies: 4
    Last Post: 03-12-2006, 02:17 PM
  3. Just a postfix clarification.
    By SlyMaelstrom in forum C++ Programming
    Replies: 3
    Last Post: 12-08-2005, 09:47 AM
  4. Infix to Postfix
    By dat in forum C Programming
    Replies: 6
    Last Post: 06-16-2003, 08:46 AM
  5. postfix
    By datainjector in forum C Programming
    Replies: 11
    Last Post: 11-20-2002, 08:33 PM