Łańcuchy znaków - sortowanie(problem po kompilacji)

0

Witam, mam problem z wynikami programu po skompilowaniu(nie sortuje):

#include <stdio.h>
#include <string.h>
#define ROZMIAR 81
#define IND 20


void sort(char *tab[], int num);

int main(void)
{
	char temp[IND][ROZMIAR];
	char *tab[IND];
	int i=0, k;
	printf("Podaj imie i nazwisko (ENTER jesli 'koniec', max wyrazen=%d)\n", IND);
	while(i<IND && gets(temp[i])!= NULL && temp[i][0] != '\0' )
	{
		tab[i]=temp[i];
		i++;
		}
	sort(tab, i);
	puts("\nPosortowana tablica:\n");
	for(k=0;k<i;k++)
	puts(tab[k]);
	
	return 0;
}
void sort(char *tab[], int num)
{
	char *temp;
	int a,b;
	for(a=0; a<num-1; a++)
	 for(b=a+1; b<num; b++)
	 
		if(strcmp(tab[a], tab[b]) > 0)
	{	
		temp=tab[a];
		tab[a]=tab[b];
		tab[a]=temp;
			
			
	}
}
0

Takie błędy najtrudniej znaleźć:

                temp=tab[a];
                tab[a]=tab[b];
                tab[a]=temp;

zamień na:

 
                temp=tab[a];
                tab[a]=tab[b];
                tab[b]=temp;

1 użytkowników online, w tym zalogowanych: 0, gości: 1