1. 程式人生 > 實用技巧 >2021.1.3學習日記(水仙花數問題)

2021.1.3學習日記(水仙花數問題)

技術標籤:函式指標

函式指標

1.函式指標

/********************************
*函式指標
********************************/

#include <stdio.h>

static int first_drv_open()
{
    printf("first_drv_open\n");
    return 0;
}

static int first_drv_read()
{
    printf("first_drv_read\n");
    return
0; } struct file_operations_imitative { int (*open) (); int (*read) (); int (*write) (); }; int Func(); /*宣告一個函式*/ int (*p) (); /*定義一個函式指標*/ int main() { /**instance analysis1 簡單的例子**/ p = Func; /*將Func函式的首地址賦給指標變數p*/ p(); /**instance analysis1 根據核心仿寫**/
struct file_operations_imitative my_operation; my_operation.open = first_drv_open; my_operation.read = first_drv_read; my_operation.open(); my_operation.read(); return 0; } int Func() { printf("%s %d\n",__FUNCTION__, __LINE__); return 0; }

在這裡插入圖片描述