C和指针 练习 1-4

来源:互联网 发布:linux学生管理系统 编辑:程序博客网 时间:2024/05/14 17:32
#include <stdio.h>#define MAX_LEN 1001int main(void){    char input[MAX_LEN];    int len;    char longest[MAX_LEN];    int longest_len = -1;    while(gets(input) != NULL && *input != '\0')    {        if((len = strlen(input)) > longest_len)        {            longest_len = len;            strcpy(longest, input);        }    }    if(longest_len >= 0)        puts(longest);    return 0;}
原创粉丝点击