diff options
author | zlg <zlg@zlg.space> | 2013-02-13 20:43:28 -0600 |
---|---|---|
committer | zlg <zlg@zlg.space> | 2013-02-13 20:43:28 -0600 |
commit | b30a821e7b8e646d2d041f83611fc40cccfe032f (patch) | |
tree | c97e31990681f2770dc0a6a5ca16a7c73815b9a0 | |
parent | Fix Exercise 1-12's solution (diff) | |
download | knr-b30a821e7b8e646d2d041f83611fc40cccfe032f.tar.gz knr-b30a821e7b8e646d2d041f83611fc40cccfe032f.tar.bz2 knr-b30a821e7b8e646d2d041f83611fc40cccfe032f.tar.xz knr-b30a821e7b8e646d2d041f83611fc40cccfe032f.zip |
Fix 1-09's solution
My initial solution tried to simplify the conditions for outputting a
space. You really do need two 'if's in there.
Diffstat (limited to '')
-rw-r--r-- | 1-09_single-spacing.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/1-09_single-spacing.c b/1-09_single-spacing.c index 82447ee..4bf802a 100644 --- a/1-09_single-spacing.c +++ b/1-09_single-spacing.c @@ -15,8 +15,10 @@ int main(void) { int spaces = 0; while ((c = getchar()) != EOF) { - if (c == ' ' && spaces == 0) { - putchar(c); + if (c == ' ') { + if (spaces == 0) { + putchar(c); + } spaces++; } else { putchar(c); |