首先给大家分享一个巨牛巨牛的人工智能教程,是我无意中发现的。教程不仅零基础,通俗易懂,而且非常风趣幽默,还时不时有内涵段子,像看小说一样,哈哈~我正在学习中,觉得太牛了,所以分享给大家!点这里可以跳转到教程
在学习嵌入式我们经常和结构体函数指针打交道,还有链表,环形缓冲区之类的,这里中点讲解结构体中定义函数指针。下面这个程序你看一遍你基本也明白用法了。
下面是我写的一个很简单的程序struct.c
#include <stdio.h> /* 标准输入输出头文件 */
#include <stdlib.h> /* strtoul用到的头文件 */
struct test_pfun { /* 定义一个结构体,里面有三个成员,是三个函数指针 ,前面千万不要加static,这里并没有分配内存*/
int (*add) (int a,int b);
int (*sub) (int a,int b);
int (*mult) (int a,int b);
};
static int test_add(int a,int b) /* 定义求和函数 */
{
return (a+b);
}
static int test_sub(int a,int b) /* 定义相减函数 */
{
return (a-b);