19 lines
1.2 KiB
Plaintext
19 lines
1.2 KiB
Plaintext
|
Pogromist said It's a snake, you just didn't check it before it went away,Mental disorder is also enforcing particular code style by a compiler itself, instead of using linter. I understand if there's no other way because there's no brackets like in python (but it's interpreter so idk).,@Demolishun
|
||
|
struct Point {
|
||
|
int x, y;
|
||
|
} p, *pPtr;
|
||
|
|
||
|
I only knew about this from this syntax, but at the same time didn't correlate with regular variable syntax of pointers.,Arent' they in the cloud tho? /j,Reminds me of this,@Lensflare
|
||
|
when it's regular struct declaration, the names before ';' or after '}' are variable declarations of that struct
|
||
|
struct Point { int x, y; } p, *pPtr;
|
||
|
struct Point { int x, y; } p = { 5, 5 }; // you can even initialize it there
|
||
|
struct { int x, y; } p, *pPtr; // variables of that unnamed struct could be declared only once
|
||
|
|
||
|
When it's typedef it makes alias for "struct Point"
|
||
|
typedef struct Point { int x, y; } Point, *PointPtr;
|
||
|
So you can use "Point p = { 5, 5 };" instead of "struct Point p = { 5, 5 };"
|
||
|
When it's anonymous typedef
|
||
|
typedef struct { int x, y; } Point, *PointPtr;
|
||
|
you can only use "Point p" and not "struct Point p"
|
||
|
And it's useful when the type name shows that it's a pointer
|
||
|
PointPtr p = (PointPtr)malloc(sizeof(Point));```
|