ptr.c

来自「里面包含很多c语言的源码」· C语言 代码 · 共 29 行

C
29
字号
/* Demonstration of declaring and using a pointer to a function.*/

#include <stdio.h>

/* The function prototype. */

double square(double x);

/* The pointer declaration. */

double (*ptr)(double x);

int main( void )
{
   /* Initialize p to point to square(). */

     ptr = square;

    /* Call square() two ways. */
    printf("%f  %f\n", square(6.6), ptr(6.6));
    return 0;
}

double square(double x)
{
    return x * x;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?