diff --git a/cv1/program.c b/cv1/program.c index 8079f00..9a0ebf4 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,11 +1,32 @@ #include +#include -char simulate_caps_lock(char c) { - if ('a' <= c && c <= 'z') { - return c - ('a' - 'A'); - } else if ('A' <= c && c <= 'Z') { - return c + ('a' - 'A'); - } else { - return c; +int main() { + char input_char; + int line_count = 0; + + while (1) { + int read_result = scanf("%c", &input_char); + + 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; } +