call a struct in c code example
Example: function inside struct c
typedef struct client_t client_t, *pno;
struct client_t
{
pid_t pid;
char password[TAM_MAX]; // -> 50 chars
pno next;
pno (*AddClient)(client_t *); <-- pointer to function
};
pno client_t_AddClient(client_t *self) { /* code */ } <-- function
int main()
{
client_t client;
client.AddClient = client_t_AddClient; // probably really done in some init fn
//code ..
client.AddClient(&client);
}