All'interno del main , nel ciclo while non incrementi nessuna variabile i++

La chiamata alla funzione ordina() mettila fuori dal while , cosi come la stampa dei dati su file.



codice:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct corridore{
	char nome[200];
	char naz [20];
	char sqd[20];
	int time;
};

void ordina(struct corridore *classifica, int num){
	int i, j;
	struct corridore temp;
	for (i=(num-1); i>=0; i--){
		for (j=1; j<=i; j++){
			if (classifica [j-1].time > classifica[j].time){
				temp=classifica[j-1];
				classifica[j-1] = classifica[j];
				classifica[j] = temp;
			}
		}
	}
	
}
	
int main(int argc, char *argv[]){
	FILE *fin, *fout;
	char buf [2048];
	int num;
	int i=0;
	int h=0, m=0, s=0;
	fin = fopen (argv[1], "r");
	fout = fopen (argv[2], "w");
	
	fgets (buf, sizeof(buf), fin);				/*Legge la prima riga che indica quanti partecipanti in gara*/
	num = atoi(buf);
	struct corridore *classifica = malloc(sizeof(struct corridore) *num);
	if (classifica == NULL){
		printf("Rilevato errore nella classifica\n");
		return -1;
	}
	
	while (fgets (buf,sizeof(buf), fin) != NULL){
		strcpy (classifica[i].nome, strtok(buf, ",:"));	/*Mette in nome, l'i*esimo nome da tok*/
		strcpy (classifica[i].naz, strtok(NULL, ",:"));	/*Mette in naz, l'i*esimo nome da tok*/	
		strcpy (classifica[i].sqd, strtok(NULL, ",:"));	/*Mette in sqd, l'i*esimo nome da tok*/
		
		{h = atoi(strtok(NULL, ":"));
		 m = atoi(strtok(NULL, ":"));
		 s = atoi(strtok(NULL, ":"));
		 classifica[i].time = (h*3600 + m*60 + s); /*Mette in time il tempo calcolato in secondi*/
		 //CORREZZIONE **********
		 i++; //INCREMENTO DI I NON ERA PRESENTE
		 
		}
		 
		

	}
	
        ordina(classifica, num);//ordina(classifica, num);
       //CORREZZIONE ***************
	for(i=0;i<num;i++) //FOR PER STAMPARE DOPO ORDINATO
		fprintf(fout, "%s  %ds\n", classifica[i].nome, classifica[i].time);
	fclose(fin);
	fclose(fout);
	system("pause");
	return 0;
}