Converting Chars to Ints, then arithmatic...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Converting Chars to Ints, then arithmatic...

  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Converting Chars to Ints, then arithmatic...

    In this program I'm supossed to recieve an infix expression from a user. Then convert it into a postfix expression and finally evaluate the postfix expression.

    This is a program using Stacks by the way.

    I am stuck trying to evaluate my postfix expression( string). I'm supossed to add operands from the postfix expression to a stack. Once I get to a +, /, *, - char in the postfixExp I have to "pop the top of the stack" twice.
    The "pop" method returns the popped chars to the DP.

    Now this is where I'm in agony!!!!

    I will have to convert the 2 popped CHARS to INTS then perform the app. operation depending on the current operator. Once I get the result of the operation I have to convert it back to a char and add it into the stack..

    The CHAR to INT conversion leave the INTs with the Unicode and I dunno what to do now!!!!!

    - How do I use the +, -, *, / operations if the INTS are in Unicode?!?!?!?!?!?

    I would appriciate it if you would tell me pretty much the code, not pseudocode, cause I know what to do I just don't know how to do it. Also please tell me how to covert the result from an INT back to a CHAR!!

    I normally do my own work but I'm annoyed, tired and stressed. This program is due Monday and I have another do Wensday. I wanna get them done by Monday to hand both in on same disk!!!


    THANKS FOR YOUR HELP!!

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    If you haven't already found out:
    Code:
      char c = 'H';
      int i = c;
      char c2 = (char)i;
    ArchAngel.
    O:-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center