Find the answer to your Linux question:
Results 1 to 2 of 2
i want to have a user to enter numerical values in a text field, then I take these values and send them to various functions. But heres the trick, the ...
  1. #1
    Just Joined!
    Join Date
    Dec 2003
    Posts
    41

    Gtk programming help

    i want to have a user to enter numerical values in a text field, then I take these values and send them to various functions. But heres the trick, the user is only going to be entering hexadecimal values.
    One way that may work is to use gtk_entry_new () to get the text field up and running. But it seems as if it will only return string types. How do I covert this to hex? Or mayb there another way of accomplishing this?

    --thanks.

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Alrighty. So you have the string returned by the entry. You now need to use glibc's strtol function. The basic form will be:
    Code:
    int number = (int) strtol(your_number, NULL, 16);
    Read the man page for strtol: it's pretty cool.

    Hope that helps!
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...