Skip to content

Instantly share code, notes, and snippets.

@Todai88
Created April 24, 2017 08:31
Show Gist options
  • Save Todai88/28e9fa292b98a69af957a1c6b874f92d to your computer and use it in GitHub Desktop.
Save Todai88/28e9fa292b98a69af957a1c6b874f92d to your computer and use it in GitHub Desktop.
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