1 /*- 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)getline.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 #include <stdio.h> 13 14 getline(s, lim) /* get line into s, return length */ 15 char s[]; 16 int lim; 17 { 18 int c, i; 19 20 i = 0; 21 while (--lim > 0 && (c=getchar()) != EOF && c != '\n') 22 s[i++] = c; 23 if (c == '\n') 24 s[i++] = c; 25 s[i] = '\0'; 26 return(i); 27 } 28