You are here:

C/Can you please tell what does that error mean??

Advertisement


Question
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
char a[]="Hello";
while(a!='\0')
{
printf("%c",*a);
a++; ====>>>>>ERROR is here: 'Lvalue required'
}

What is that Lvalue,

Why cant we move on to next address location by performing a++;

Please explain me sir.
Thanking you.

Answer
Hi Akshay,

According to the ISO/IEC 9899:1999 International Standard document, this happens for the following reasons. In the error message "Lvalue" is derived from the left operand of an assignment expression. The "++" operator will only work with a modifiable lvalue. An array type is not a modifiable lvalue. You can solve this issue by storing the address of the array in a pointer.

Example:

#include<stdio.h>
int main()
{
char a[]="Hello";
char *x = a;
while(*x!='\0')
{
printf("%c",*x);
x++;
}
return 0;
}

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tony Nazzal

Expertise

I will answer any c language programming and syntax questions.

Experience

I have almost a decade of c programming experience.

Education/Credentials
I have a bachelor of science degree and several years of industry experience.

©2016 About.com. All rights reserved.