Re: http://www.gtk.org/tutorial/sec-anupgradedhelloworld.html



On Thu, Feb 17, 2005 at 01:05:43PM +0100, Gert Cuykens wrote:
static void callback( GtkWidget *widget, gpointer   data ){
    g_print ("Hello again - %s was pressed\n", (gchar *) data);
}

why do they put () around gchar ?

In C, it's called a cast.

why can it not be gchar *data ?

Because that would be invalid C, a syntax error.

What does %s do ?

It's a format specifier, it gets replaced with the string data
points to.

See 'man printf' for details.

Are gpointer and gchar global variables of gtk ?
Are gpointer and gchar data types or objects ?

They're basic types of GLib. See 

http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html

What does gpointer and gchar represent ?

Well, gpointer represents a generic pointer and gchar represents a
character corresponding to the standard C char type.


I suggest that you get a good book on C programming so that you get
at first familiar with the language before you start programming with
GTK. Beginner questions for C are a bit off topic on this ML, I think.


HTH
--
Claudio



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