L
lector
in my code i am seperate components or modules. suppose
foo2.c
int foo2(int *a)
{
/* some operations which vary the value of a
the function returns 0 if successful or 1 if failure is
encountered. */
}
foo.c
#include "foo2.h"
#include <stdio.h>
int main(void)
{
int a,i;
i= foo2(&a);
if(i==1)
{
printf("failure");
return(EXIT_FAILURE);
}
else
{
printf("%d",a);
return(EXIT_SUCCESS);
}
}
when call a function and pass adress to it then it is call by
reference. the function foo2 will change the value at the address
given to it as parameter. but my question is won't the variable be
destroyed after the function foo2() is over ? if we make a variable
extern then is it true that it will appear everywhere in the whole
code with the same value ?
foo2.c
int foo2(int *a)
{
/* some operations which vary the value of a
the function returns 0 if successful or 1 if failure is
encountered. */
}
foo.c
#include "foo2.h"
#include <stdio.h>
int main(void)
{
int a,i;
i= foo2(&a);
if(i==1)
{
printf("failure");
return(EXIT_FAILURE);
}
else
{
printf("%d",a);
return(EXIT_SUCCESS);
}
}
when call a function and pass adress to it then it is call by
reference. the function foo2 will change the value at the address
given to it as parameter. but my question is won't the variable be
destroyed after the function foo2() is over ? if we make a variable
extern then is it true that it will appear everywhere in the whole
code with the same value ?