S
Stephen Mayes
I'm afraid I'm not in school, so I have no-one to ask but you nice folks.
I learned most of this stuff from lurking around here, anyway.
Are there any problems with this code?
It appears to work on the (free) compilers I have.
#include <stdio.h>
struct _my_struct;
typedef void(callback_function) (struct _my_struct * arg);
typedef struct _my_struct
{
int data;
callback_function * cb_func;
} my_struct_t;
void any_callback_function (my_struct_t * b)
{
b->data <<= 1;
}
void test (my_struct_t * a)
{
a->cb_func (a);
}
int main (void)
{
my_struct_t ms = {0};
ms.data = 1234;
ms.cb_func = any_callback_function;
test (&ms);
printf ("%d\n", ms.data);
return 0;
}
I learned most of this stuff from lurking around here, anyway.
Are there any problems with this code?
It appears to work on the (free) compilers I have.
#include <stdio.h>
struct _my_struct;
typedef void(callback_function) (struct _my_struct * arg);
typedef struct _my_struct
{
int data;
callback_function * cb_func;
} my_struct_t;
void any_callback_function (my_struct_t * b)
{
b->data <<= 1;
}
void test (my_struct_t * a)
{
a->cb_func (a);
}
int main (void)
{
my_struct_t ms = {0};
ms.data = 1234;
ms.cb_func = any_callback_function;
test (&ms);
printf ("%d\n", ms.data);
return 0;
}