Created
April 18, 2015 11:08
-
-
Save tomcha/1fc44e39b02ead8cd339 to your computer and use it in GitHub Desktop.
2-2
This file contains hidden or 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
| #include <stdio.h> | |
| #define MAXCHARS 1000 | |
| void getlined(char s[], int lim); | |
| int main(){ | |
| char s[MAXCHARS]; | |
| getlined(s, MAXCHARS); | |
| printf("%s\n", s); | |
| } | |
| void getlined(char s[], int lim){ | |
| int i; | |
| int c; | |
| // for(i=0; i< lim - 1 && (c = getchar()) != '\n' && c != EOF; i++){ | |
| for(i=0; !(i>= lim - 1 || (c = getchar()) == '\n' || c == EOF); i++){ | |
| s[i] = c; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment