Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI801.ASC

 
Output of file : TI801.ASC contained in archive : BCPPTECH.ZIP







PRODUCT : C++ NUMBER : 801
VERSION : All
OS : DOS
DATE : February 25, 1992 PAGE : 1/1

TITLE : Defining and Using Arrays of Pointers to Functions




The following demonstrates how to define and initailize an array
of pointers to functions. In addition, calling a function whose
pointer is contained in such an array is demonstrated.

#include

void (*p[5])(); // p is defined to be an array of
// 5 pointers to functions taking
// no (void) paramaters and returning
// nothing (void)

void foo1(void) { printf("Hello, in function foo1\n"); }
void foo2(void) { printf("Hello, in function foo2\n"); }

main()
{
p[0]=foo1; // Assign pointer at array index 0
// to point at function foo1.
p[0](); // Now call foo1


p[1]=foo2; // Assign pointer at array index 1
// to point to function foo2.
p[1](); // Now call foo2
}


























  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI801.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/