function inside struct c

Solutions on MaxInterview for function inside struct c by the best coders in the world

showing results for - "function inside struct c"
Maylis
06 Sep 2016
1typedef struct client_t client_t, *pno;
2struct client_t
3{
4        pid_t pid;
5        char password[TAM_MAX]; // -> 50 chars
6        pno next;
7
8        pno (*AddClient)(client_t *);  <-- pointer to function    
9};
10
11pno client_t_AddClient(client_t *self) { /* code */ } <-- function
12
13int main()
14{
15
16    client_t client;
17    client.AddClient = client_t_AddClient; // probably really done in some init fn
18
19    //code ..
20
21    client.AddClient(&client);
22
23}
24