From 2a8f1f3bafd94aa1d82763bc77b9152e782b0985 Mon Sep 17 00:00:00 2001 From: VIliam Date: Sun, 25 Feb 2024 21:23:20 +0100 Subject: [PATCH] capslock --- cv1/program.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 89c0ecd..8d9e1a2 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,25 +1,29 @@ #include -#include int main() { - int line_count = 0; - char input_char; + int c; + int lineCount = 0; - while ((input_char = getchar()) != EOF) { - if (input_char == '\n') { - line_count++; + while ((c = getchar()) != EOF) { + if (c >= 'a' && c <= 'z') { + + c = c - 'a' + 'A'; + } else if (c >= 'A' && c <= 'Z') { + + c = c - 'A' + 'a'; } - if (islower(input_char)) { - input_char = toupper(input_char); - } else if (isupper(input_char)) { - input_char = tolower(input_char); + if (c == '\n') { + + lineCount++; } - putchar(input_char); + + putchar(c); } - printf("\nLines␣count:%d\n", line_count); + + printf("\nPočet načítaných riadkov: %d\n", lineCount); return 0; }