In K&R Chapter 6, a declaration is mentioned as follows:
struct{
int len;
char *str;
} *p;
I couldn't understand which structure is this pointer p pointing to and if such a pointer definition is even valid because in all other examples given in the book and the ones I have seen otherwise, when defining a pointer to a structure, the name of the structure, that is, the type being defined needs to be mentioned. For example,
struct example{
int a;
...
}s1;
and then,
struct example *ptr = &s1;
so, it is mentioned that ptr is pointing to a type struct example and not just struct.
Also, of particular interest was this:
*p->str fetches whatever str points to; *p->str++ increments str after accessing whatever it points to (just like *s++);
I couldn't follow what p is in the first place, hence, not the increment and dereference as well.
What is going on here?
Thanks in advance!
P.S. I am new here, so any feedback on the format of the question would also be appreciated.