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



On Thu, 2005-02-17 at 13:05 +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 ?
why can it not be gchar *data ?

gpointer is a void pointer and the call to g_print is expecting a gchar
pointer, hence the use of (gchar *) to change the pointer type.

What does %s do ?

Same as in printf, look at the man page: man 3 printf.

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

You should consult a beginners guide to C programming so that you can
understand pointers and data types properly.  There are also a number of
introductory C tutorials on the web, just search Google.

Keith.




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