Lvalue required error

You can’t do a++ on a static array – which is not an Lvalue. You need to do on a pointer instead. Try this:

int *ptr = a;
int i;
for(i=0;i<5;i++)
{
    printf("\n%d",*ptr);
    ptr++;
}

Although in this case, it’s probably better to just use the index:

int i;
for(i=0;i<5;i++)
{
    printf("\n%d",a[i]);
}

Leave a Comment