Edit: I now see that the original question was tagged C
and not C++
and someone erroneously tagged it C++
(reverted the tagging).
One solution, as others mentioned, is to add a typedef
before the struct
declaration however since this is C++
(according to the question's tag) and not C
a more idiomatic and shorter way would be to just drop the trailing "String"
struct String {
int length;
int capacity;
unsigned check;
char ptr[0];
};
This is enough to introduce a type called String
the reason your original code didn't work was that in addition to introducing a type called String
you introduced a variable called String
which hid the type.