From a60014d7fac08ba1df11bff02d6b5f9eb5cb67fa Mon Sep 17 00:00:00 2001 From: celso Date: Mon, 7 Nov 2022 22:55:14 -0300 Subject: [PATCH] sixteenth exercise --- 1-16.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 1-16.c diff --git a/1-16.c b/1-16.c new file mode 100644 index 0000000..2fa7dcd --- /dev/null +++ b/1-16.c @@ -0,0 +1,45 @@ +#include +#define MAXLINE 1000 /* maximum input line length */ + +/* ggetline: read a line into 'line', return length */ +int ggetline(char line[], int maxline){ + int c, i; + for (i=0; (c=getchar()) != EOF && c!='\n'; ++i){ + if (i0){ + if (len > max){ + max = len; + copy(longest, line); + } + } + if (max > 0){ /* there was a line */ + printf("%s\n", longest); + printf("length: %d\n", max); + } + return 0; +}