problem in displaying array elements

#include<stdio.h>
#include<conio.h>
int *fun()
{
int i[]={1,2,3,4,5};
return &i[0];
}
void main()
{
int *p;
int i;
clrscr();
p=fun();
for(i=0;i<5;i++)
{
printf("%d\n",*(p+i)); // problem in displaying array elements
}
getch();
}
Last edited on
buzzy i think you d't know how to solve it

anyway
i came to know that i as to declare an array as static/ global
Last edited on
Topic archived. No new replies allowed.