i have a confusion in it
#include <stdio.h>
#include <stdlib.h>
void add(int,int);
int main(int argc, char *argv[])
{
add(6,3);
printf("%d",p);
system("PAUSE");
return 0;
}
void add(int a, int b)
{
static int p;
p = a+ b;
}
here the memory layout says variable "p" is in BSS segment ... so its an
independent region from stack frame..... when the function looses its scope
from function defination(add) then still it should be alive... and can be
recognized/used by other function(main).... but it gves an error of unknown
variable "p"..... need the correct logic....... if i m wrong...
thanx
ravi
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.