From: Cian Bagshaw Date: Sun, 7 May 2023 08:15:11 +0000 (+0100) Subject: 1-16 X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;p=cProgLang 1-16 --- diff --git a/1/16.c b/1/16.c new file mode 100644 index 0000000..f276e88 --- /dev/null +++ b/1/16.c @@ -0,0 +1,43 @@ +/* + Exercise 1-16. Revise the main routine of the longest-line program so it will + correctly print the length of arbitrarily long input lines, and as much as + possible of the text. + === +*/ + +#include + +#define MAX 1000 /* max line length */ + +/* read line into string, l, of length size, s, return length */ +int readline(char l[], int s) { + int c, i; + for (i=0; im) { /* if longest */ + m=l; copy(line, lngst); /* record it */ + } + } + if (m) /* if lines were processed, print longest */ + printf("%d: %s\n", m-1, lngst); +}