From 3aa99bdd09d646df2d0a51b6761dc7671c42fb56 Mon Sep 17 00:00:00 2001 From: Artem Horbunov Date: Thu, 5 Mar 2020 21:17:34 +0100 Subject: [PATCH] funguje --- du1/program.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/du1/program.c b/du1/program.c index ee536c1..b5dbf90 100644 --- a/du1/program.c +++ b/du1/program.c @@ -1,12 +1,14 @@ #include +#include int main(){ int c = 0; + char text[256]; while(1){ char ch; int num = 'a' - 'A'; scanf("%c", &ch); - if(ch == 'q' || ch == -1){ + if(ch == EOF || ch == -1){ break; } c++; @@ -18,8 +20,19 @@ int main(){ ch -= num; c--; } - printf("%c", ch); + text[c] = ch; } - printf("Počet riadkov: %d\n", c); + printf("%d\n", strlen(text)); + for(int i = 0; i < c; i++){ + if(text[i] != '\n'){ + printf("%c\n", text[i]); + } + else{ + printf("\n"); + } + + } + printf("%d\n", c); } +