]>
zdv2.bktei.com Git - BK-2023-05.git/blob - src/kr_exercises/ch1/s1.9/array_test.c
5 int mygetline(char line
[], int maxline
); /* 'my-' to avoid name collision */
11 while( (len
=mygetline(line
, MAXLINE
)) > 0 ) {
19 /* mygetline: read a line into s, \0-term, return length v2 */
20 int mygetline(char s
[], int lim
) {
23 /* Read chars into s[] until lim reached */
24 for (i
=0; i
<lim
-1 && (c
=getchar())!=EOF
&& c
!='\n'; ++i
)
26 j
= i
; /* Store char count for counting beyond lim */
28 /* \0 terminate array s[] */
35 /* Count up remaining chars beyond lim until EOF or '\n' reached */
37 while ( (c
=getchar()) != EOF
&& c
!= '\n')
43 /* Return char count (including chars beyond array limit)*/