Skip to content

Commit 90d1dd6

Browse files
Fixed uninitialized value
Fixed the uninitialized value in chapter 1, exercise 9. If last_c was randomly assigned a space, a leading space would never be printed. The fix is to ensure that last_c is always initialized to a value that is not a space to prevent this situation.
1 parent 678dc80 commit 90d1dd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

chapter_1/exercise_1_09/copy_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int main(void)
44
{
55
char c;
6-
char last_c;
6+
char last_c = '\0';
77
while ((c = getchar()) != EOF)
88
{
99
if (c != ' ' || last_c != ' ')

0 commit comments

Comments
 (0)