You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
443 B

/*
* word.c
*
* Created on: Jun 13, 2013
* Author: delmadord
*/
#include <stdio.h>
#include "word.h"
int read_char(void) {
int ch = getchar();
if (ch == '\n' || ch == '\t')
return ' ';
return ch;
}
int read_word(char *word, int len) {
int ch, pos = 0;
while ((ch = read_char()) == ' ')
;
while (ch != ' ' && ch != EOF) {
if (pos < len)
word[pos++] = ch;
ch = read_char();
}
word[pos] = '\0';
return pos;
}