Reputation: 11
error: invalid type argument of unary '*' (have 'int')
struct test_t {
int var1[5];
int var2[10];
int var3[15];
}
test_t* test;
test->var1[0] = 5;
How can I solve this problem?
Upvotes: 1
Views: 3109
Reputation: 3992
When you declare a structure variable, struct
keyword should be there like
struct test_t* test;
If you don't want to use struct
keyword every time you declare a variable, simply use typedef
.
Upvotes: 0
Reputation: 95958
You should write:
struct test_t* test;
Or use typedef
if you want to avoid writing struct
every time you declare a variable of that type:
typedef struct test_t {
int var1[5];
int var2[10];
int var3[15];
} test_t;
test_t* test;
Side note: In C++ the struct name is placed in the regular namespace, therefore there is no need to write struct
before declaring a variable of that type.
Upvotes: 3