From 508110160bbb2fd7634e825830894bf40e4c89b0 Mon Sep 17 00:00:00 2001 From: Weber Date: Wed, 21 Feb 2024 18:58:37 +0000 Subject: [PATCH] Update 'cv1/program.c' --- cv1/program.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 8d2936c..e8b1973 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,4 +1,5 @@ #include +#include int main() { char ch; @@ -7,9 +8,13 @@ int main() { while ((ch = getchar()) != EOF) { if (ch == '\n') { line_count++; - putchar('\n'); } else { - putchar((ch >= 'a' && ch <= 'z') ? (ch - 32) : ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch)); + if (isprint(ch)) { + putchar((ch >= 'a' && ch <= 'z') ? (ch - 32) : ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch)); + } + else { + putchar(ch); + } } }