From 2cd846ed3033c92f050182cb67fa4898b6d64a34 Mon Sep 17 00:00:00 2001 From: Sophia Weber Date: Sun, 28 Jan 2024 18:17:35 +0100 Subject: [PATCH] add oct String output --- src/main.c | 1 + src/outputHandling.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 9c7787d..10e0a7b 100644 --- a/src/main.c +++ b/src/main.c @@ -13,5 +13,6 @@ void main() { printf("Geben Sie eine Rechenoperation ein (Bsp.: 1+1):\n"); fgets(inputBuffer, STRING_LENGTH, stdin); //fgets statt scanf, holt den kompletten String inkl. Whitespace processInput(inputBuffer, strlen(inputBuffer)); + result.result = 65478; printResult(&result); } diff --git a/src/outputHandling.c b/src/outputHandling.c index 0a00670..bd1a3a6 100644 --- a/src/outputHandling.c +++ b/src/outputHandling.c @@ -6,10 +6,16 @@ void hex(char* string, int number) { sprintf(string, "%X", number); } +void oct(char* string, int number) { + sprintf(string, "%o", number); +} + void printResult(calc_op* result) { char buf[60] = {0}; printf("Das Ergebnis ist: %f\n", result->result); - printf("Das Ergebnis in int: %i\n",(int)result->result); + printf("Das Ergebnis in dec: %i\n",(int)result->result); hex(buf, (int)result->result); printf("Das Ergebnis in hex: 0x%s\n", buf); ; + oct(buf, (int)result->result); + printf("Das Ergebnis in oct: %s\n", buf); ; } \ No newline at end of file