#include <stdio.h>

typedef struct _team {

char name[21];

int W;

int L;

int D;

int S;

int OS;

} Team;

void swap(Team *team1, Team *team2){

Team temp;

temp = *team1;

*team1 = *team2;

*team2 = temp; //I can do this with structures right? Or do I have to swap each of the components?

}

void bubblesort(Team teams[], int totals){

int i,j;

for(i=totals-1; i>0; i--){

for(j=0; j < i; j++){

if(compare(teams[j],teams[j+1])==0){ //function used here has no problems, so I won't bother writing it again.

swap(&teams[j], &teams[j+1]);

}

}

}

}

void new_team(Team teams[], int *totals, char team[]){//assume you have n teams, then the last one is on n-1 position on teams[], so the next will be on n position.

int i=0;

while(team[i]!='\0'){

teams[*totals].name[i] = team[i];

}

teams[*totals].W = 0;

teams[*totals].L = 0;

teams[*totals].D = 0;

teams[*totals].S = 0;

teams[*totals].OS = 0;

*totals++;**//at this point, let's totals goes to 1. BUT...**

}

int find_position(Team teams[], int *totals, char team[]){//Given a string with the name of a team, I want to know what position is it, and if it's in neither, I'll add it to the vector.

int i,j;

i = 0;

j = 0;

while(i<*totals && j != '\0'){

if (teams[i].name[j] == team[j]){

if(team[j]=='\0'){return i;}

j++;

}

else{i++; j=0;}

}

new_team(teams, totals, team);

**//At this point, right after exiting the function, totals is 0.**

return *totals-1;

}

void update(Team teams[50], int *totals, char team1[21], int s, int os){

int i;

i = find_position(teams,totals,team1);

teams[i].S = teams[i].S + s;

teams[i].OS = teams[i].OS + os;

if (s>os){teams[i].W++;}

if(os>s){teams[i].L++;}

if(os==s){teams[i].D++;}

}

int main() {

Team teams[50];

char team1[21], team2[21];

int games, totals, i, s1, s2;

scanf("%d", &games);

ntimes = 0;

for (i = 0; i < games; i++) {

scanf("%s %d x %d %s", team1, &s1, &s2, team2);

update(teams, &totals, team1, s1, s2);

update(teams, &totals, team2, s2, s1);

}

bubblesort()(teams, totals);

print_table(teams, totals);

return 0;

}

Can you see what is wrong with the pointer issue? Well, if it's the case I might post the rest of the functions, but since the issue is mainly in the interaction from update,find_position and new_team I think this might be enough.
agrees : Well said