date and time created 88/12/14 16:21:45 by marc
[unix-history] / usr / src / usr.bin / learn / objects / getline.c
CommitLineData
0af5b5a6
JK
1#ifndef lint
2static char sccsid[] = "@(#)getline.c 1.1 (Berkeley) %G%";
3#endif not lint
4
5#include <stdio.h>
6
7getline(s, lim) /* get line into s, return length */
8char s[];
9int lim;
10{
11 int c, i;
12
13 i = 0;
14 while (--lim > 0 && (c=getchar()) != EOF && c != '\n')
15 s[i++] = c;
16 if (c == '\n')
17 s[i++] = c;
18 s[i] = '\0';
19 return(i);
20}