E
Excluded_Middle
what is wrong with this code
#include <stdio.h>
typedef struct s1
{
int a;
int b;
}s1;
int main()
{
s1 *tmp;
tmp = (s1 *)calloc(10,sizeof(s1));
if(tmp == NULL) /* Error checking done */
tmp[5]->a = 90;
tmp[5]->b = 239;
printf("a is %d\n",tmp[5]->a);
printf("b is %d\n",tmp[5]->b);
free(tmp);
return 0;
}
in this program i want to create a dynamic array of s1. and then i
want to access each element using array notation like tmp[5] for the
6th element in the array.
thats what i get when I compile it using cc comand on linux OS
buffer.c: In function `main':
buffer.c:16: invalid type argument of `->'
buffer.c:17: invalid type argument of `->'
buffer.c:19: invalid type argument of `->'
buffer.c:20: invalid type argument of `->'
#include <stdio.h>
typedef struct s1
{
int a;
int b;
}s1;
int main()
{
s1 *tmp;
tmp = (s1 *)calloc(10,sizeof(s1));
if(tmp == NULL) /* Error checking done */
tmp[5]->a = 90;
tmp[5]->b = 239;
printf("a is %d\n",tmp[5]->a);
printf("b is %d\n",tmp[5]->b);
free(tmp);
return 0;
}
in this program i want to create a dynamic array of s1. and then i
want to access each element using array notation like tmp[5] for the
6th element in the array.
thats what i get when I compile it using cc comand on linux OS
buffer.c: In function `main':
buffer.c:16: invalid type argument of `->'
buffer.c:17: invalid type argument of `->'
buffer.c:19: invalid type argument of `->'
buffer.c:20: invalid type argument of `->'