Number converter, MSVC++ 5.0

This is a discussion on Number converter, MSVC++ 5.0 within the Windows Programming forums, part of the Platform Specific Boards category; I've been working on a program to try to convert a number from one base to another. I've been trying ...

  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, 01:56 PM
  2. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 02: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, 05:25 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 01:42 PM

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