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); } +