Thread: Float to char *

  1. #1
    Unregistered
    Guest

    Float to char *

    I have a float that I want to display on a messagebox, which gets LPCSTR type. I tried (char *)&i but it didnt work. (i is the float). How can it be done??

    Thank you

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I tried (char *)&i but it didnt work.
    Indeed.

    sprintf(buff, "The Value Is: %.2f", myFloat);

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    34
    Maybe that is why most OOP languages (.net and java) read all user input into strings as the first state of the input.

  4. #4
    Unregistered
    Guest
    it worked, thank you. i didnt know sprintf could do that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Promblem with code
    By watchdogger in forum C Programming
    Replies: 18
    Last Post: 01-31-2009, 06:36 PM
  2. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  3. help me
    By warthog89 in forum C Programming
    Replies: 11
    Last Post: 09-30-2006, 08:17 AM
  4. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  5. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 11:57 AM