13_strings/p14.c
/* Will read at most n - 1 bytes into the provided buffer or until a newline
 * or EOF is found. Will always store a null byte at the end. Will leave
 * remaining characters on the stream.
 */
Will read at most n - 1 bytes into the provided buffer or until a newline
or EOF is found. Will always store a null byte at the end. Will leave
remaining characters on the stream.
Will read at most n - 1 bytes into the provided buffer or until a newline or EOF is found . Will always store a null byte at the end . Will leave remaining characters on the stream .
void read_word(char *word, int n) {
    int c;
    char *p = word;
    for (; p < word + (n - 1); p++) {
        c = getchar();
        if (c == '\n') {
            *p = c;
            break;
        } else if (c == EOF) {
            break;
        } else if (isalpha(c)) {
            *p = c;
        }
    }
    *p = '\0';
}
void read_word ( char * word , int n ) { int c ; char * p = word ; for ( ; p < word + ( n - 1 ) ; p ++ ) { c = getchar ( ) ; if ( c == ' \n ' ) { * p = c ; break ; } else if ( c == EOF ) { break ; } else if ( isalpha ( c ) ) { * p = c ; } } * p = ' \0 ' ; }
Will read at most n - 1 bytes into the provided buffer or until a newline
 or EOF is found.
Will read at most n - 1 bytes into the provided buffer or until a newline or EOF is found .