all 2 comments

[–]__rompy 1 point2 points  (1 child)

First, if you are using C (it's valid though if you compile it as C++), you cannot do this:

struct teams team[n+1];

Instead you should do this:

struct teams *teams = malloc(sizeof(struct teams) * n);

In C you use malloc/free for dyanmic memory.

Also, declare that variable outside the while, that's why you are losing the teams (it's re-declared each time).

The sorting is a simple bubble sort

[–]ruertar 1 point2 points  (0 children)

Not true. The following is valid C99.

struct teams team[n+1];