how to correct this error here the code is given below. "Lvalue required"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramya123
    New Member
    • Jan 2012
    • 2

    how to correct this error here the code is given below. "Lvalue required"

    Code:
    void main()
    {
    char a, *b, c[3];
    a= 0xaa;
    b = &a;
    c[0]= a;
    c[9] = *b + 10;
    c[1] = *(c+9)++;
    *c = *b--;
    printf(“%s\n”,c);
    }
    Last edited by Banfa; Jan 23 '12, 02:17 PM. Reason: Use code tags, next time don't just post code. Post you question and a complete listing of any compiler errors.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Line 8: (c+9) is a pointer and you can't apply the increment operator to a pointer. Did you mean (*(c+9)++?

    Among other errors in your program

    1. Line 1: main returns int not void
    2. Line 4: 0xaa is greater than the value you can store in a signed char
    3. Line 7: c[9] is out of range for the array c which only has a size of 3 and therefore valid indexes 0, 1, 2

    Comment

    Working...