Thread: Converting CString to int ??

  1. #1
    Registered User
    Join Date
    Jul 2002

    Unhappy Converting CString to int ??

    I'm using Visual C++
    in my text box i assign a CString variable
    and i want to convert it to integer. How can i do it ?
    CString = "5+5*5"
    converts to
    int = 5+5*5

    actually i have assigned before a int variable to the textbox
    but when i insert 5+5, the int variable only contain 5 not 5+5.
    so i assigned a CString variable

    Please help me, and thanks you very much.
    i'm planning to make a calculator for my course's project.

    Well i already tries atoi() but it just didn't work.
    i think it can't convert the arithmatic operator (-,+,*,/)
    plssss help me...

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Use atoi, get all the numbers, then go back and get the operators. Then, do the arithmetic operations on them. A useful function for this would be strpbrk()

  3. #3
    Registered User
    Join Date
    Jul 2002

    Still couldn't figure it out

    i still confused ????
    the problem is visual c++ can't read if we input "5+5" for integer ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory leak
    By aruna1 in forum C++ Programming
    Replies: 3
    Last Post: 08-17-2008, 10:28 PM
  2. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  3. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  4. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM