From 95b84588982e4c564315570351019258f41164e8 Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Fri, 3 Apr 2020 07:19:49 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu4/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du4/program.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/du4/program.c b/du4/program.c index c12b6dc..4fd753e 100644 --- a/du4/program.c +++ b/du4/program.c @@ -1,3 +1,6 @@ +/* +gcc -Werror -std=c11 -Wall in-out.c -lm -o in-out -lm && ./in-out +*/ #include #include #include @@ -45,9 +48,9 @@ int main(){ if(cond<0){ printf("CHYBA\n"); return 0;} - /*if((fcond=checkend())!='\n'){ - printf("1CHYBA %d\n",(int)fcond); - return 0;}*/ + if((fcond=checkend())!='\n' && fcond>0){ + printf("CHYBA\n"); + return 0;} if(fcond==-1) break; //printf("%lf %c %lf = %lf\n",list[i].na,list[i].sign,list[i].nb,list[i].result); @@ -70,8 +73,15 @@ char checkend(void){ while((c=getchar())){ ++count; if(c==EOF || c=='\n'){ + int a=c; + if((c=getchar())==EOF){ + ++count; + fseek(stdin,-count,SEEK_CUR); + return c; + } + ++count; fseek(stdin,-count,SEEK_CUR); - return c; + return a; } else if(!isspace(c)){ fseek(stdin,-count,SEEK_CUR);