Created
April 24, 2017 08:31
-
-
Save Todai88/28e9fa292b98a69af957a1c6b874f92d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
while((len = get_line(line, MAXLINE)) > 0) { | |
printf("%s", line); | |
} | |
} | |
int get_line(char line[], int limit) { | |
int current, index; | |
for (index = 0; index < limit -1 && (current = getchar()) != EOF && current != '\n'; ++index) | |
line[index] = current; | |
if (current == '\n') { | |
line[index] = current; | |
++index; | |
} | |
line[index] = '\0'; | |
return index; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment