hi...Sorry,this is a basic question about function. I tried to find the solution from net but failed. Here is a sample code of C
#include<stdio.h>
int mult(int); //prototype
main()
{
int a;
printf(" Enter the Integer!");
scanf("%d",&a);
printf("2x%d is %d",a,mult(a)); //call function
}
int mult(int x) //function definition
{
return x*2;
}
What is the relation between prototype and function definition in term of address in memory. int mult(int)/prototype-means that user requires 4 byte space in memory with a specific address and how about int mult(int x)/function defination??From my understanding, function definition also requires 4 byte space in memory but at a diferent address with prototype.
What was confusing me is, why prototype is needed in the code because the calculation of function is done in function definition. Or what is the function of prototype and does it requires space in memory.
I am a newer in programming and may be my understanding about the whole things above is wrong. Please correct my understanding if I am wrong...
Thanks.
#include<stdio.h>
int mult(int); //prototype
main()
{
int a;
printf(" Enter the Integer!");
scanf("%d",&a);
printf("2x%d is %d",a,mult(a)); //call function
}
int mult(int x) //function definition
{
return x*2;
}
What is the relation between prototype and function definition in term of address in memory. int mult(int)/prototype-means that user requires 4 byte space in memory with a specific address and how about int mult(int x)/function defination??From my understanding, function definition also requires 4 byte space in memory but at a diferent address with prototype.
What was confusing me is, why prototype is needed in the code because the calculation of function is done in function definition. Or what is the function of prototype and does it requires space in memory.
I am a newer in programming and may be my understanding about the whole things above is wrong. Please correct my understanding if I am wrong...
Thanks.