函数指针数组和函数指针数组指针

#include <iostream>

char * func0(char * str)
{
	printf("func0 %s
", str);
	return NULL;
}

char * func1(char *str)
{
	printf("func1 %s
", str);
	return NULL;
}

char * func2(char *str)
{
	printf("func2 %s
", str);
	return NULL;
}

int main()
{
	char *(*pbuf[3])(char*);
	pbuf[0] = func0;
	pbuf[1] = func1;
	pbuf[2] = func2;

	char *(*(*ptr)[3])(char *);

	ptr = &pbuf;

	*pbuf[0]("wei");
	*pbuf[1]("you");
	*pbuf[2]("qing");

	(*ptr)[0]("wei1");
	(*ptr)[1]("you1");
	(*ptr)[2]("qing1");

	ptr[0][0]("wei2");
	ptr[0][1]("you2");
	ptr[0][2]("qing2");

	char *(*(*p))(char*);
	p = pbuf;
	*p[0]("wei3");
	*p[1]("you3");
	*p[2]("qing4");

	system("pause");
	return 0;
}

  

原文地址:https://www.cnblogs.com/weiyouqing/p/12933342.html