Re: Structs



On Mon, Oct 30, 2000 at 09:17:53PM -0500, Josh 'Gage' wrote:

int main( int argc, char *argv[] )
{
    struct_t *struct;
               ^^^^^^^^
    
you are defining this variable as a pointer without allocating
space for it.

either malloc space for it, or define it as NOT a pointer (in which
case space is allocated for it on the stack automatically). Putting
it on the stack is preferred as long as you don't need to use it
after the function it is defined in returns (not a problem for
main...)

if it's defined statically, replace '->' with '.' in the rest of
the code and it should work. If you malloc space for it, leave the
rest of the code as is.

    struct_t->widget1 = gtk_widget_new("useless widget 1");
    struct_t->widget2 = gtk_widget_new("useless widget 2");

    gtk_widget_show( struct_t->widget1 );
    gtk_widget_show( struct_t->widget2 );
    ...

hope that helps,

Conrad.




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