Laurin
11 months ago
1 changed files with 58 additions and 0 deletions
@ -0,0 +1,58 @@ |
|||
#include "conversionOfNumbers.h" |
|||
#include "../userinput.h" |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
int main(){ |
|||
int minInput = 0; |
|||
int maxInput = 2; |
|||
int InputMainMenu; |
|||
while(InputMainMenu != 3){ |
|||
|
|||
printf("\nWaehle Zahlensystem:\n" |
|||
"\n<0> Binaer System\n" |
|||
"<1> Hexadezimal System\n" |
|||
"<2> Beenden\n"); |
|||
InputMainMenu = usergetd("\nEingabe: ", &minInput, &maxInput); |
|||
if(InputMainMenu == 2) break; |
|||
int InputOptionsMenu; |
|||
|
|||
while(InputOptionsMenu != 3){ |
|||
|
|||
printf("\nZu oder von einer Dezimalzahl konvertieren?\n" |
|||
"\n<0> Zu\n" |
|||
"<1> Von\n" |
|||
"<2> Hauptmenue\n"); |
|||
InputOptionsMenu = usergetd("\nEingabe: ", &minInput, &maxInput); |
|||
if(InputOptionsMenu == 2) break; |
|||
if(InputMainMenu == 0){ |
|||
if(InputOptionsMenu == 0){ |
|||
char* toConvert = usergets("\nGeben Sie eine Zeichenkette von 0 und 1 ein: ", NULL, NULL); |
|||
int result = convertBinaryStrToInt(toConvert); |
|||
printf("\nAusgabe (in Dezimal): %d\n", result); |
|||
} |
|||
if(InputOptionsMenu == 1){ |
|||
int toConvert = usergetd("\nGeben Sie eine Ganzzahl ein: ", NULL, NULL); |
|||
char* result = convertIntToBinaryStr(toConvert); |
|||
printf("\nAusgabe (in Binaer): %s\n", result); |
|||
free(result); |
|||
} |
|||
} |
|||
if(InputMainMenu == 1){ |
|||
if(InputOptionsMenu == 0){ |
|||
char* toConvert = usergets("\nGeben Sie eine Zeichenkette im Hexadezimal-Format ein: ", NULL, NULL); |
|||
int result = convertHexStrToInt(toConvert); |
|||
printf("\nAusgabe (in Dezimal): %d\n", result); |
|||
} |
|||
if(InputOptionsMenu == 1){ |
|||
int rangeMin = 0; |
|||
int toConvert = usergetd("\nGeben Sie eine positive Ganzzahl ein: ", &rangeMin, NULL); |
|||
char* result = convertIntToHex(toConvert); |
|||
printf("\nAusgabe (in Hex): %s\n", result); |
|||
free(result); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return 0; |
|||
} |
Reference in new issue
xxxxxxxxxx