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