I have following program which won't complie. Can someone help locate the problem here ?
when I compile I get following error on marked lines.Code:
#include <stdio.h>
#define max 10
struct a
{
int a1;
};
struct b
{
int a_cnt;
struct a *strt_a[max];
};
struct c
{
struct b strt_b;
};
int main(int argc, char *argv[])
{
struct c *strt_c;
strt_c = (struct c *)malloc(sizeof(struct c));
strt_c->strt_b.a_cnt=0;
strt_c->strt_b->strt_a[strt_c->strt_b.a_cnt] = (struct a *)malloc(sizeof(struct a)); /*line 26*/
strt_c->strt_b->strt_a->a1=1234; /*line 28*/
printf("strt_c->strt_b->strt_a->a1: %d\n",strt_c->strt_b->strt_a->a1); /*line 30*/
free(strt_c->strt_b->strt_a[strt_c->strt_b.a_cnt]); /*line 32*/
free(strt_c);
return 0;
}
Thanks,Quote:
ptr10.c: In function `main':
ptr10.c:26: invalid type argument of `->'
ptr10.c:28: invalid type argument of `->'
ptr10.c:30: invalid type argument of `->'
ptr10.c:32: invalid type argument of `->'