Skip to content

Commit 4935490

Browse files
authored
Update copy_io.c
changed chars to ints to avoid "comparison between pointer and integer gcc" warning
1 parent 69f5fe4 commit 4935490

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

chapter_1/exercise_1_09/copy_io.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
int main(void)
44
{
5-
char c;
6-
char last_c = '\0';
5+
int c;
6+
int last_c = '\0';
7+
/*
8+
If I use chars here instead of ints I get a "comparison
9+
between pointer and integer gcc" warning.
10+
getchar returns int not char.
11+
Char type is de facto a 1-byte integer type.
12+
Thank you for you solutions, they're helping me learn.
13+
*/
714
while ((c = getchar()) != EOF)
815
{
916
if (c != ' ' || last_c != ' ')

0 commit comments

Comments
 (0)