#include "stdafx.h"
#include<stdio.h>
#include<string.h>
#define N 5
#define M 81
char *fun(char (*sq)[M])
{int i;
char *p;
p=sq[0];
for(i=1;i<N;i++)
if(strlen(p)<strlen(sq[i]))
{p=sq[i];}
return p;
}
void main()
{char str[N][M],*longest;
int i;
printf("Enter %d lines:
",N);
for(i=0;i<N;i++)
gets(str[i]);
printf("
The %d string:
",N);
for(i=0;i<N;i++)
puts(str[i]);
longest=fun (str);
printf("
The longest:
");
puts(longest);
}
c语言找最长字符串,为什么我这个只能输出字符组,输出不了最长字符串呢
发布时间:2019-02-22 19:41