#include<stdio.h>
#include<string.h>
typedef int (*fnptr)(int,int);
typedef char (*cptr)(char*,char*);
int add(int a,int b){
int sum;
sum=a+b;
return sum;
}
char chptr(char* a,char* b){
char c;
printf("%s",a);
}
int main(){
fnptr fp;
fp=&add;
int r=fp(5,6); //or (*fp)(5,6)
printf("%d",r);
cptr ch;
ch=&chptr;
char c=(*ch)("zh","g");
printf("%c",c);
}
//imp one about pointers
#include <stdio.h>
typedef int (*fptr)(int*, int*);
int add(int *a,int *b){
int sum;
sum = *a+*b;
return sum;
}
int main(){
fptr fp;
int a = 5,b=7;
fp = &add;
int out = fp(&a,&b);
printf("%d",out);
}
To embed this program on your website, copy the following code and paste it into your website's HTML: