diff --git a/code/practise/15 编写大型程序/01 文本格式化/justify.c b/code/practise/15 编写大型程序/01 文本格式化/justify.c index 44c1a27..ef1d818 100644 --- a/code/practise/15 编写大型程序/01 文本格式化/justify.c +++ b/code/practise/15 编写大型程序/01 文本格式化/justify.c @@ -17,7 +17,7 @@ int main(void) { // read_word 1 ַʳȳ 20Ҫض read_word(word, MAX_WORD_LEN + 1); word_len = strlen(word); - if (word == 0) { + if (word_len == 0) { flush_line(); return 0; } diff --git a/code/practise/15 编写大型程序/01 文本格式化/line.c b/code/practise/15 编写大型程序/01 文本格式化/line.c index fe99bf9..078743b 100644 --- a/code/practise/15 编写大型程序/01 文本格式化/line.c +++ b/code/practise/15 编写大型程序/01 文本格式化/line.c @@ -47,7 +47,7 @@ void write_line() { putchar(line[i]); else { spaces_to_insert = extra_space / num_words; // ѭʽӿո - for (j = 0; j < spaces_to_insert; j++) + for (j = 0; j <= spaces_to_insert; j++) // ʹ = ȷٴӡһ putchar(' '); extra_space -= spaces_to_insert; num_words--; diff --git a/code/practise/15 编写大型程序/01 文本格式化/line.h b/code/practise/15 编写大型程序/01 文本格式化/line.h index 85d197c..19e0e00 100644 --- a/code/practise/15 编写大型程序/01 文本格式化/line.h +++ b/code/practise/15 编写大型程序/01 文本格式化/line.h @@ -45,13 +45,4 @@ void write_line(); *********************************************************/ void flush_line(void); - -/******************************************************** -* -* -* -* -* -*********************************************************/ - #endif \ No newline at end of file