#include<stdio.h>
int main()
{
setbuf(stdout,NULL);
int a[],i,lim,sum=0;
printf("Enter the limit of the array: ");
scanf("%d",&lim);
printf("Enter the values: ");
for(i=0;i<lim;i++)
{
scanf("%d",&a[i]);
}
int *p;
for(p=&a[0];p<lim;p++)
{
sum=sum+*p;
}
printf("Sum= %d",sum);
return 0;
}
While running the code I'm getting the following error
..\src\Test6.c: In function 'main':
..\src\Test6.c:5:6: error: array size missing in 'a'
..\src\Test6.c:14:15: warning: comparison between pointer and integer
Please help me understand why I've to declare the array size when I have no issues doing the same without pointers.
Or please help me understand what change should I make to rectify the error:)