双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

程序运行无误,却无法得到结果

mailghyth mailghyth 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <stdio.h>

#define MAXLINE 1000

int getliness(char lon[], int lim); /*获取输入的字符,存入数组并返回长度
void copyss(char to[], char from[]); /*复制数组

main()
{
int len, max;
char lon[MAXLINE];
char maxest[MAXLINE];

max = 0;
while ((len = getliness(lon, MAXLINE)) > 0)
if (len > max){
max = len;
copyss(maxest, lon);
}
if (max > 0) /*如果存在最大字符串,则输出
printf("%s", maxest);
return 0;
}

int getliness(char line[], int lim)
{
int c, i;

for (i = 0; i < lim -1 && (c = getchar() != EOF) && c != '\n'; i++)
line[i] = c;
if (c = '\n'){
line[i] = c;
++i;
}
line[i] = '\0';

return i;
}

void copyss(char to[], char from[])

{
int i;

i = 0;
while (to[i] = from[i] != '\0')
++i;
}

程序在gcc下运行无误,输入字符串若干,按下ctrl+d却无法得到结果,直接没反应,另外想问以下main()函数里的return 0;这一句有什么用阿,什么意思,感觉多余的
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
mailghyth
C语言 70,039 成员 243,237 内容