C语言 用指针统计二维字符数组中的最大字符串
#include<string.h> #include<stdlib.h> char * find_max_string(char a[][300],int n) { char *pmax; int i, j = 0, k; for (i = 0; i < n; i++) { k = strcmp(a[j],a[i]); if (k < 0) { j = i; } } pmax = &a[j-1][300]; return pmax; } int main() { char a[10][300]={"afsdfas","asdfasdf","werqwrqwe","asfdasdfatewt"},*p; int n=10; p=find_max_string(a,n); puts(p); return 0; }