Struct prototype before the main()

c, prototype, struct

Solution

This declaration:

typedef struct Point;

is not valid in C.

How could I achieve that right ?

typedef struct Point {
   int x;
   int y;
} Point;

int main() {
    Point p1 ,p2 ; 
}

You cannot achieve the same with `struct Point` declaration after `main` because the implementation has to know the storage of `Point` objects `p1` and `p2` when you declare them in `main`.

Problem

Having a `struct` - `typedef struct Point{ .... }` I want to write its `prototype` before the `main()` , something like - ``` typedef struct Point ; int main() { Point p1 ,p2 ; ... } typedef struct Point { int x; int y; } Point; ``` The above gives me error - `unknown type name 'Point'` . How could I achieve that right ? Edit: I know that it would be work if I define to `struct` before the `main()` . I just want to know whether it have any `prototye` similarly to `function prototye`.

Original source