This commit is contained in:
Džubara 2024-02-24 20:02:50 +01:00
parent 5803f2d996
commit 9eedfad604

View File

@ -1,11 +1,32 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
char simulate_caps_lock(char c) { int main() {
if ('a' <= c && c <= 'z') { char input_char;
return c - ('a' - 'A'); int line_count = 0;
} else if ('A' <= c && c <= 'Z') {
return c + ('a' - 'A'); while (1) {
} else { int read_result = scanf("%c", &input_char);
return c;
if (read_result == EOF) {
break;
}
if (islower(input_char)) {
printf("%c", toupper(input_char));
} else if (isupper(input_char)) {
printf("%c", tolower(input_char));
} else if (input_char == '\n') {
line_count++;
printf("%c", input_char);
} else if (isprint(input_char)) {
// Print visible characters as they are
printf("%c", input_char);
} }
} }
printf("\nNumber of lines read: %d\n", line_count);
return 0;
}