0
我試着去弄清楚ķ& [R運動1-12的差異,跨越這個答案跌跌撞撞:我不明白K&R運動這個代碼示例1-12
#include <stdio.h>
#define IN 1
#define OUT 0
main()
{
int c, state;
state = OUT;
while ((c = getchar()) != EOF) {
if (c != ' ' && c != '\n' && c != '\t') {
state = IN;
putchar(c);
}
else
if (state == IN) {
state = OUT;
putchar('\n');
}
}
if (state == IN)
putchar('\n');
}
請告訴我的
目的if (state == IN)
putchar('\n');
如果我把它拿出來的代碼它仍然運行完全相同。請有人向我解釋將這個額外的if語句放入代碼的目的。
也有沒有更簡單的方法來寫這段代碼而不使用書本章之前的東西?
我明白你的意思了。謝謝。 – MrEMB 2015-02-11 15:20:13