Thread: Number converter, MSVC++ 5.0

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    2

    Question Number converter, MSVC++ 5.0

    I've been working on a program to try to convert a number from one base to another. I've been trying to use itoa() to do this, as it seems to have the necessary input fields. For some reason the program won't put a value into the edit box that should recieve it. I don't know whether the problem lies in my code (a single function and the edit boxes), or the itoa() function. I'm not getting any error codes. I'm including the dialog c++ file.


    void CBaseconverterDlg::OnConvert()
    {
    // TODO: Add your control notification handler code here

    char *pointer, holder[256];

    pointer = &holder[128];

    m_Target = *itoa(m_Source, pointer, m_Base);

    UpdateData(TRUE);
    UpdateData(FALSE);
    }

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    first you dont need to have the poniter, a simple char array will work fine with itoa. Also itoa is not returning the array, it just returns some garbage, you call it like this:
    Code:
    char holder[256];
    int target = 1001;
    int BASE = 2;
    itoa(target, holder, BASE);
    The above will convert to binary. Also i believe that itoa will only convert up to 33 bits. So your largest number you can convert would be: 4294967295
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  2. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  3. Finding a number within a number
    By jeev2005 in forum C Programming
    Replies: 2
    Last Post: 01-10-2006, 08:57 PM
  4. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM