access variable...



Hi,

sorry for the silly question but how do I access the variables.... see my code below...

#include <stdlib.h>
#include <glib.h>

gboolean
tempo(gpointer data)
{
    gint j = 0;
    j = (gint)(data->i); // HOW TO ACCESS THE STRUCTURES VARIABLES???
    g_print("%d", j);
    return TRUE;
}


gint
main(gint argc, gchar *argv[])
{
    GMainLoop *loop;
    struct
    {
    gint i;
    } *udata;
    udata = g_malloc(sizeof(gint) + sizeof(gchar));
    udata->i = 1;
   
    g_print("Delay: %s. ", argv[1]);
    g_print("i: <%d>\n", udata->i);
    g_timeout_add(g_ascii_strtod(argv[1], NULL), (GSourceFunc)tempo, (gpointer)udata);
    loop =  g_main_loop_new(NULL, TRUE);
    g_main_loop_run(loop);
   
    return 0;
}


--
-- Yianni

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