From a1a819fa6b4dc06925dcf92bcb535fef452e5c5d Mon Sep 17 00:00:00 2001 From: Michal Utlak Date: Wed, 14 Feb 2024 16:36:27 +0100 Subject: [PATCH] nieco --- cv1/program.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 5ee1842..a7368f5 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,6 +1,29 @@ #include +#include -int main(){ - printf("Hello World!\n"); - return 0; +int main() { + int ch; + int visibleChars = 0; + + printf("Zadajte text (ukoncite vstup s Ctrl+D):\n"); + + while ((ch = getchar()) != EOF) { + if (islower(ch)) { + ch = toupper(ch); + } else if (isupper(ch)) { + ch = tolower(ch); + } + + if (isprint(ch) || ch == '\n') { + putchar(ch); + if (ch != '\n') { + visibleChars++; + } + } + } + + printf("\nPocet načítaných riadkov: %d\n", visibleChars); + + return 0; } +