Help Please!

This is a discussion on Help Please! within the C Programming forums, part of the General Programming Boards category; I was wondering how I can take a string entered in and separate it so I can use individual characters. ...

  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21