how to access the element in an array in structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jinnejeevansai
    New Member
    • Nov 2014
    • 48

    how to access the element in an array in structure

    #include <stdio.h>
    struct stack{
    int n,,a[100];
    }s;
    int main()
    { int i;
    scanf("%d",&s.n );
    printf("%d",s.n );
    for(i=0;i<3;i++ )
    {
    scanf("%d",&s.a[i]);
    printf("%d",s.a[i]);
    }
    return 0;
    }
    this program is not running why can't i access elements in this way directly.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    It's nothing to do with accessing the array element. It has to do with those two commas in the struct. You can have only one comma. Two commas may be valid in other languages but not in C.C++.

    Comment

    Working...