C typedef of pointer to structure

c, pointers, struct, typedef

Solution

Absolutely valid. Usually, you can take full advantage of this way by defining two types together:

typedef struct
{
 int a;
 int b;
} S1, *S1PTR;

Where S1 is a struct and S1PTR is the pointer to this struct.

Problem

I had come across the following code: ``` typedef struct { double x; double y; double z; } *vector; ``` Is this a valid type definition? The code compiles and runs fine. I was just curious if this is common practice.

Original source