📜  struct 中的函数 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:41.910000             🧑  作者: Mango

代码示例1
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);

}