/*‘&’ is used to get the address of the variable.
C does not have a string type, String is just an array of characters
and an array variable stores the address of the first index location.
By default the variable itself points to the base address and therefore
to access base address of string, there is no need of adding an extra ‘&’
*/
#include <stdio.h>
#if 0
void name(char *a){
printf("The name of pgm is %s",a);
}
int main(){
char n1[10];
//scanf("%s",n1); only reads till " " namespace
//fgets(n1,10,stdin);
// ptr is a pointer to function fun():- name()
void (*ptr)(char *)=&name;
/* The above line is equivalent of following two
void (*ptr)(int);
ptr = &fun;
*/
// Invoking fun():- name using ptr
//name(n1); //this is the printing line to fn
//function call using function pointer
(*ptr)("Adarsh Hi");
//ptr=&name;
}
#endif
//#if 0
//pointer to function
#include <stdio.h>
void name(char *a){
printf("The name of pgm is %s",a);
}
int main(){
char n[10];
scanf("%s",n);
name(n);
printf("The name of pgm is %s",n);
}
//#endif
To embed this program on your website, copy the following code and paste it into your website's HTML: