#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main01()
{
char a0[30] = "22222222";
char a1[30] = "11111111";
char a2[30] = "bbbbbbbb";
char a3[30] = "aaaaaaaa";
char a[][30] = { "22222222","11111111","bbbbbbbb","aaaaaaaa" };
printf("a:%d, a+1:%d\n", a, a + 1);
char b[30];
printf("&b:%d, &b+1:%d\n", &b, &b + 1);
for (int i = 0; i < 4; i++)
{
printf("%s\n", a[i]);
}
printf("\n");
system("pause");
return 0;
}
void printArray(char a[][30], int n)
{
for (int i = 0; i < n; i++)
{
printf("%s, ", a[i]);
}
printf("\n");
}
void sortArray(char a[][30], int n)
{
char tmp[30];
for (int i = 0; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
if (strcmp(a[i], a[j]) > 0)
{
strcpy(tmp, a[i]);
strcpy(a[i], a[j]);
strcpy(a[j], tmp);
}
}
}
}
int main()
{
char a[][30] = { "22222222","11111111","bbbbbbbb","aaaaaaaa" };
int n = sizeof(a) / sizeof(a[0]);
printf("before sort:\n");
printArray(a, n);
sortArray(a, n);
printf("\nafter sort:\n");
printArray(a, n);
printf("\n");
system("pause");
return 0;
}