Commit | Line | Data |
---|---|---|
0af5b5a6 JK |
1 | #ifndef lint |
2 | static char sccsid[] = "@(#)getline.c 1.1 (Berkeley) %G%"; | |
3 | #endif not lint | |
4 | ||
5 | #include <stdio.h> | |
6 | ||
7 | getline(s, lim) /* get line into s, return length */ | |
8 | char s[]; | |
9 | int 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 | } |