Browse Source

Create Output Handling

remotes/origin/Input_Handling
Sophia Weber 11 months ago
parent
commit
83aec72e1e
  1. 4
      src/inputHandling.c
  2. 3
      src/main.c
  3. 8
      src/outputHandling.c
  4. 8
      src/outputHandling.h
  5. 20
      test/test_outputHandling.c

4
src/inputHandling.c

@ -85,7 +85,7 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //proces
} }
void showStruct(calc_op* formulaRef){ void showStruct(calc_op* formulaRef){
printf("Berechnung: %s\n", formulaRef->formular);
printf("\nBerechnung: %s\n", formulaRef->formular);
switch (formulaRef->functionsType) { switch (formulaRef->functionsType) {
case opAdd: case opAdd:
printf("Rechenoperation: Addition\n"); break; printf("Rechenoperation: Addition\n"); break;
@ -102,5 +102,5 @@ void showStruct(calc_op* formulaRef){
for (int arrayCount = 0; arrayCount < formulaRef->arrayLength; ++arrayCount) { for (int arrayCount = 0; arrayCount < formulaRef->arrayLength; ++arrayCount) {
printf("Array[%i] = %f\n", arrayCount, formulaRef->inputNumbers[arrayCount]); printf("Array[%i] = %f\n", arrayCount, formulaRef->inputNumbers[arrayCount]);
} }
printf("Result: %f", formulaRef->result);
printf("Result: %f\n", formulaRef->result);
} }

3
src/main.c

@ -1,5 +1,6 @@
#include "helloWorld.h" #include "helloWorld.h"
#include "inputHandling.h" #include "inputHandling.h"
#include "outputHandling.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -8,7 +9,9 @@
char inputBuffer[STRING_LENGTH] = {0}; char inputBuffer[STRING_LENGTH] = {0};
void main() { void main() {
calc_op result;
printf("Geben Sie eine Rechenoperation ein (Bsp.: 1+1):\n"); printf("Geben Sie eine Rechenoperation ein (Bsp.: 1+1):\n");
fgets(inputBuffer, STRING_LENGTH, stdin); //fgets statt scanf, holt den kompletten String inkl. Whitespace fgets(inputBuffer, STRING_LENGTH, stdin); //fgets statt scanf, holt den kompletten String inkl. Whitespace
processInput(inputBuffer, strlen(inputBuffer)); processInput(inputBuffer, strlen(inputBuffer));
printResult(&result);
} }

8
src/outputHandling.c

@ -0,0 +1,8 @@
#include <stdio.h>
#include "outputHandling.h"
#include "inputHandling.h"
void printResult(calc_op* result) {
printf("Das Ergebnis ist: %f", result->result);
}

8
src/outputHandling.h

@ -0,0 +1,8 @@
#ifndef OUTPUTHANDLING_H
#define OUTPUTHANDLING_H
#include "inputHandling.h"
extern void printResult(calc_op* result);
#endif // OUTPUTHANDLING_H

20
test/test_outputHandling.c

@ -0,0 +1,20 @@
#ifdef TEST
#include "unity.h"
#include "outputHandling.h"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_outputHandling_NeedToImplement(void)
{
TEST_IGNORE_MESSAGE("Need to Implement outputHandling");
}
#endif // TEST
Loading…
Cancel
Save