diff --git a/cv3/program.c b/cv3/program.c index 23ac35d..1c5748f 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -48,13 +48,13 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){ temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) / atof(buffer[currentlyInBuffer-1]))*100)/100; } - for(int i = currentlyInBuffer-3; currentlyInBuffer > i; currentlyInBuffer--) - memset(buffer[currentlyInBuffer], SIZE, '\0'); + for(int i = currentlyInBuffer-2; currentlyInBuffer > i; currentlyInBuffer--) + memset(buffer[currentlyInBuffer], '\0', SIZE); gcvt(temporaryDecimal, 10, buffer[currentlyInBuffer++]); - for(int i = 0; i <= currentlyInBuffer; i++){ - if(i == currentlyInBuffer) + for(int i = 0; i < currentlyInBuffer; i++){ + if(i == currentlyInBuffer-1) printf("%0.2f \n", roundf(atof(buffer[i]) * 100) / 100); else printf("%0.2f ", roundf(atof(buffer[i]) * 100) / 100); @@ -64,6 +64,7 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){ } else{ printf("bad input\n"); + return false; } } @@ -80,4 +81,4 @@ int main() { printf("no input\n"); return 0; -} +} \ No newline at end of file