#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 50
void sorting(char *arr[], int n)
{
int i,pass;
char t = (char ) malloc(20);
for(pass=0; pass<=n-2; pass++)
{
for(i=0; i<=n-2; i++)
{
if(stricmp(arr[i], arr[i+1])>0)
{
strcpy(t, arr[i]);
strcpy(arr[i], arr[i+1]);
strcpy(arr[i+1], t);
}
}
}
}
void main()
{
char *city[MAX];
int i, n;
printf(“\nHow many strings? “);
scanf(“%d”, &n);
fflush(stdin);
for(i=0; i<n; i++)
{
printf("Enter city name; ");
city[i] = (char *)malloc(20);
gets(city[i]);
}
sorting(city, n);
printf("\nSorted city names: \n");
for (i=0; i<n; i++)
{
puts(city[i]);
}
system("pause");
}
“`