Re: Cast from gchar* to int?
- From: John Coppens <jcoppens usa net>
- To: "William L. Thomson Jr." <support obsidian-studios com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Cast from gchar* to int?
- Date: Tue, 24 Sep 2002 17:45:21 -0300
On 24 Sep 2002 11:34:18 -0700
"William L. Thomson Jr." <support obsidian-studios com> 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));
If num_entry is an entry, you maybe better off using
an_int = gtk_entry_get_text(GTK_ENTRY(num_entry));
Else you'll have to g_free() the pointer returned by gtk_editable_get_chars.
other than that, what is the problem? What's going wrong?
Mind and important item: You're _not_ casting a char* to an int here. You
are converting a character string into an integer, which means it'll always
fail if there's any illegal character is in it.
John
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.
--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone 707.766.9509
Fax 707.766.8989
http://www.obsidian-studios.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]