Lvalue Required For Function Main

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MukeshL
    New Member
    • Sep 2014
    • 1

    #1

    Lvalue Required For Function Main

    Hello Experts !!

    I actually am wanting to practice on a 2 dimension char array. so, I am using the below program and getting the error - Lvalue Required For Function Main

    #include <stdio.h>
    #include <conio.h>
    #include <string.h>

    char varStringArray[1][5];

    int main(void)
    {
    clrscr();
    varStringArray[0] = 'a';
    printf("%c", varStringArray[0]);
    return 0;
    }

    Please help.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Refer to Arrays Revealed. You define varStringArray with two dimensions, but then you only access it with one array index. The referenced article explains why this is a problem.

    However, I would have expected a different error message. There may be something else wrong with your code that I don't see.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Rather than duplicate the explanation, please read this: http://bytes.com/topic/c/insights/77...rrays-revealed.

      Then if you still have a question about this, post again and we'll go from there.

      Comment

      Working...