ASP ScriptingJava ScriptingCGI ScriptingHTMLJavaLanguage CERP Education Links

LANGUAGE C

Pointers To Functions

    Every function has a location in memory that can be assigned to pointer. A function's address is the entry point of the function. Because of this, a cunction pointer can be used to call a function.

    The address of a function can be obtained by using the function's name without any parentheses or arguments.

#include <stdio.h> 
#include <string.h>
void check (char *a, char *b, int (*cmp) () ) ;
main ( )
{
char s1[80],
s2[80];
int (*p) ( ) ;
p = strcmp;
gets(s1);
gets (s2) ;
check (s1, s2, p) ;
}
void check (char *a, char *b, int (*cmp) () )
{
printf("testing for equality \n");
if (!(*cmp) (a, b)) printf("Equal"); 
else printf("Not Equal");
}

 


Your Ad Here
Not All Of Your Subscribers Use RSS - AWeber Email Marketing
Your Ad Here