Thread: Edit boxes and integers.

  1. #1
    Registered User
    Join Date
    Aug 2005

    Edit boxes and integers.

    I've been playing around with C++ for a few weeks and decided to jump into windows programming. I have created a simple program that calculates sales tax but have run into an issue.

    The program uses edit boxes in which the user inputs values for the starting price and their local tax rate and the results are outputed into a total tax box and a total prce box (using SetDlgItemInt). The edit boxes seem to ignore the decimal points on the tax rate box. The total tax box always returns 0, but works fine if I use a number >0.

    I've looked around on these forums but I'm having a hard time figuring out what I need to do. I found references to a sprintf and atof , but the atof function appears to be for strings to floats/doubles. Something that would take a float and make it into a string might help.

    I'll post the code if neccesary, and I'm using Dev-cpp

    Thanks in advance

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Found this in less than 3 minutes of googling: It says "Convert floating point value to string." as the description of what the function does, that's what you want right?
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."

  3. #3
    Registered User
    Join Date
    Sep 2004
    sprintf() is a more portable way to convert a float to a string.
    char buff[32];
    float f = 1.5f;
    printf("the value of f is %s\n",buff);

  4. #4
    Registered User
    Join Date
    Aug 2005
    Both ways appear to work, but I like the sprintf way better!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Edit Boxes Question
    By Ruben in forum Windows Programming
    Replies: 2
    Last Post: 09-14-2001, 12:06 AM
  2. Edit Boxes Question
    By RubenJ in forum Windows Programming
    Replies: 1
    Last Post: 09-12-2001, 08:01 PM