Re: Cast from gchar* to int?
- From: Martyn Russell <ginxd btopenworld com>
- To: "William L. Thomson Jr." <support obsidian-studios com>
- Cc: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Re: Cast from gchar* to int?
- Date: Tue, 24 Sep 2002 20:18:41 +0100
William L. Thomson Jr. wrote:
This is a time when me being a newbie to C/C++ really shines.
I need to convert the string that is returned from
gtk_editable_get_chars(GTK_EDITABLE(num_entry),0,-1);
into an int.
For the life of me I can't seem to do this, and the standard C functions
do not seem to want to work either
atoi(gtk_editable_get_chars(GTK_EDITABLE(num_entry),0,-1));
I know this is a simple problem, but one I can't seem to figure out.
It's more of a language thing than GTK, but since I am doing this in my
gtk app I thought I would start by asking here. If I asked in a language
specific group, someone would comment to me being off topic.
Thanks in advance.
I seriously suggest getting a copy of this book by Brian W. Kernighan
<http://www.cs.bell-labs.com/%7Ebwk> and Dennis M. Ritchie
<http://www.cs.bell-labs.com/%7Edmr>. (here:
http://cm.bell-labs.com/cm/cs/cbook/).
But in the mean time, you should be able to get away with:
gchar *mystring = "123";
gint myint = 0;
myint = atoi(mystring);
NOTE: this is Ascii TO Integer, if you want Ascii TO Long use atol ...etc.
Regards,
Martyn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]