指针的指针字符串排序

<span style="font-size:18px;">#include<iostream>
using namespace std;
void sort(char* strings[], int n)
{
	char* temp;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (strcmp(strings[i], strings[j]) > 0)
			{
				temp = strings[i];
				strings[i] = strings[j];
				strings[j] = temp;
			}
		}
	}
}
int main()
{
	int n = 5;
	int i;
	char**p;
	char*strings[] = { "snkn", "kndg", "ljil", "nbdkj", "mklal" };
	p = strings;
	sort(p, n);
	for (int i = 0; i < n; i++)
	{
		cout << strings[i] << endl;
	}
	system("pause");
	return 0;
}</span>

你可能感兴趣的:(指针的指针字符串排序)