Thread: Help Please!

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    1

    Exclamation Help Please!

    I was wondering how I can take a string entered in and separate it so I can use individual characters.
    Example:
    user enter in "3 + 4 + 8 * 9 / 3 + 4"
    I want to get all those characters seperately and then be able to apply the order of operations.

    I'm not finding much out in any of the books I have.
    Any help will be very appreciated.

  2. #2
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    If the user is entering it all as a string, then you will need to tokenise your string. 'strtok' is useful for this. Everybody has a preference but that's an OK place to start.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    14
    You can calculate arithmetic expressions by converting it from infix to postfix form.

    eg. infix : 3+4

    postfix : 34 +

    The algorithm for this is available in Data structure books,preferably by tremblay and sorenson.

Popular pages Recent additions subscribe to a feed