X
xdevel
Hi,
in a function if I have
int * retArray()
{
int a[3] = {102,222,355};
printf("%p ", a);
return a;
}
and then in main()
int *p = retArray();
p++;
printf(" \n%p\n %d", p, *p);
the compiler warning me: ../c_test.c: In function 'retArray':
.../c_test.c:24: warning: function returns address of local variable
and for this why the array variables values are still there ?
I've studied that when the function end the local variables loosing
their values as they
are distroyed and so If I want that they are not destroyed I should use
the static word before them...
in a function if I have
int * retArray()
{
int a[3] = {102,222,355};
printf("%p ", a);
return a;
}
and then in main()
int *p = retArray();
p++;
printf(" \n%p\n %d", p, *p);
the compiler warning me: ../c_test.c: In function 'retArray':
.../c_test.c:24: warning: function returns address of local variable
and for this why the array variables values are still there ?
I've studied that when the function end the local variables loosing
their values as they
are distroyed and so If I want that they are not destroyed I should use
the static word before them...