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.
 
 

34 lines
535 B

/*
* justify.c
*
* Created on: Jun 13, 2013
* Author: delmadord
*/
#include "line.h"
#include "word.h"
#define MAX_WORD_LEN 20
int main(void) {
// additional spaces for * and \0
char word[MAX_WORD_LEN + 2];
int word_len;
clear_line();
while (1) {
word_len = read_word(word, MAX_WORD_LEN + 1);
if (word_len == 0) {
flush_line();
return 0;
}
if (word_len > MAX_WORD_LEN)
word[MAX_WORD_LEN] = '*';
if (word_len + 1 > space_remainig()) {
write_line();
clear_line();
}
add_word(word);
}
}