Re: Question about put "GtkWidget" pointer as function's argument



Could you please stop cross-posting *each* *and* *every*
your question?

On Mon, Jul 17, 2006 at 02:44:43PM +0800, chao yeaj wrote:
>          int
>          other_function()
>          {
>                  GtkWidget *splash = NULL;
> 
>                  create_image_from_file(splash);
> 
>                    /*  Here, the splash  is still  NULL, Why ?*/
>        }
> 
>         I do not know why   the splash pointer in the "other_function"
> is still NULL,i need your help ?

Function arguments in C are passed by value.
create_image_from_file() gets the value NULL in the splash
argument (a local variable), changes to it do not affect
the caller's variable. To change something in the called
functions you have to give it a *pointer* to GtkWidget*
and change the location it points to.

This is an elementary C knowledge unrelated to Gtk+, please
consult your C guide for details.

And in this case it would be silly anyway.  Why does not
the function *return* the created widget instead of some
useless constant integer?

Yeti


--
Anonyms eat their boogers.



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