Re: Hex Numbers in GtkEntry.



Hello Friends,

>Quoting Tom Froysland <Tom Froysland roma2 infn it>
Subject: Hex numbers

How is it possible to make a (text) box to get or show a hexadesimal number?
-- 

The way I do it is to use sscanf & sprintf and get/set the hexadecimal numbers
that we get respectively.

//getting an hexdecimal from the gtk_entry.
const gchar *data;
int hex_value;

data=gtk_entry_get_text(GTK_ENTRY(text_box)); 
sscanf(data,"%X",&hex_value); //Ive not done the error checking part.


//setting an hexdecimal to the gtk_entry.
gchar data=(gchar *)g_malloc(sizeof(gchar)*MAX_SIZE);
int hex_value;

sprintf(data,"%X",&hex_value); //Assume hex_value has been set somehow.
gtk_entry_set_text(GTK_ENTRY(text_box),data); 



$0.02
Cheers
Muthu.








-------------------------------------------------
This mail sent through IMP(http://www.nitt.edu)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]