#include <stdio.h>
int main()
{
char *arr[] = {"aaaa","cccc","dddd","bbbb"};//指针数组
int size = sizeof(arr) / sizeof(arr[0]);
int i = 0;
int j = 0;
for (i = 0; i < size - 1; i++)
{
for (j = 0; j < size - 1 - i; j++)
{
if (strcmp(arr[j], arr[j + 1])>0)
{
char *tmp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = tmp;
}
}
}
for (i = 0; i < size; i++)
{
printf("%s\n", arr[i]);
}
system("pause");
return 0;
}
转载于:https://blog.51cto.com/10741764/1713987