Function name in c



Feature of function name:


1. Function name is constant pointer.


Example:


What will be output of following program?


#include<stdio.h>
void special();
int main(){
   special++;
   special();
   return 0;
}
void special(){
   printf("HI");
}


Output: Error, Lvalued required.


Explanation: Function name is constant pointer. So you cannot increment function special.


2. Function name gives the address where it has defined.


#include<stdio.h>
int main(){
   int p,q;
   cquestionbank();
   printf("%u",cquestionbank);
   return 0;
}
int cquestionbank(){
   printf("");
   return 0;
}


Output: Address of function


3. We can rename the function name using typedef keyword.

No comments: