I want to know the length of C function (written by me) at runtime. Any method to get it? It seems sizeof doesn\'t work here.
You can find the length of your C function by subtracting the addresses of functions. Let me provide you an example
int function1()
{
}
int function2()
{
int a,b; //just defining some variable for increasing the memory size
printf("This function would take more memory than earlier function i.e function01 ");
}
int main()
{
printf("Printing the address of function01 %p\n",function01);
printf("Printing the address of function02 %p\n",function02);
printf("Printing the address of main %p\n",main);
return 0;
}
Hope you would get your answer after compiling it. After compiling you will able to see the difference in size of function01 and function2.
Note : Normally there is 16bytes diff between one function and other.