Advertisement
Guest User

getline.c

a guest
Jan 17th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int getline(char *line, int max);
  4.  
  5.  
  6. /**
  7.  * In difference with getline-KnR:
  8.  * this function cut '\n'
  9.  */
  10. int getline(char s[], int lim)
  11. {
  12.     int i, c;
  13.  
  14.     for (i = 0; i<lim-1 && (c=getchar())!= EOF && c!='\n'; i++)
  15.         s[i] = c;
  16.     s[i] = '\0';
  17.     return i;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement