please anyone help me to catch this.i tried to return an array from function and access it within main function.i just got a warning
"function returns address of local variable
"
and when i execute the program it gives garbage values as array elements..cam you help me pls...
#include<stdio.h>
int *foo(void);
int main()
{
int i;
int *ptr=foo();
for(i=0;i<4;i++)
printf("%d ",*(ptr+i));
return 0;
}
int *foo()
{
int ar[4]={1,2,3,4};
return ar;
}