void sort(char *name[],int n){
char * temp;
for (int i=0; i<n-1; i++) {
for (int j=1; j<n; j++) {
if (strcmp(name[i], name[j])<0) {
temp=name[i];
name[i]=name[j];
name[j]=temp;
}
}
}
}
int main(int argc, const char * argv[]) {
char *name[]={"Follow me","BASIC","Great Wall","FORTRAN","Compter Design"};
int n=5;
sort(name, n);
for (int i=0; i<5; i++) {
printf("%s\n",name[i]);
}
return 0;
}
6. 有关二维数组a的有关指针:
7.分析如下代码:
#include<stdio.h>
int main() {
// 定义一个指针变量
int a=5;
int *p =&a;
printf("p =%p\n",p);
printf("&a=%p\n",&a);
// 定义一个二级指针
int **p1 =&p;
int *p2=p;
printf("&p=%p\n",&p);
printf("p=%p\n",p1);
printf("%p",p2);