31 lines
1.0 KiB
C
31 lines
1.0 KiB
C
#include "fehler.h"
|
|
#include "bildschi.h"
|
|
#include "adturing.h"
|
|
|
|
#define MAXLEN 65 // Maximale Länge der Dualzahl (64 Bit + 1 für \0)
|
|
|
|
int main() {
|
|
char input[MAXLEN]; // Eingabepuffer für die Dualzahl
|
|
char output[MAXLEN]; // Ausgabepuffer für das Ergebnis
|
|
|
|
dualzahl_einlesen(input, MAXLEN); // Dualzahl vom Benutzer einlesen
|
|
|
|
// Prüfen, ob die Eingabe nur aus 0 und 1 besteht
|
|
for (int i = 0; input[i]; ++i) {
|
|
if (input[i] != '0' && input[i] != '1') {
|
|
fehlerausgabe("Nur 0 und 1 erlaubt!"); // Fehler ausgeben und beenden
|
|
}
|
|
}
|
|
|
|
dual_addiere_eins(input, output, MAXLEN); // 1 zur Dualzahl addieren
|
|
|
|
if (output[0] == '\0') { // Falls Fehler bei der Addition
|
|
fehlerausgabe("Fehler bei der Addition!");
|
|
}
|
|
|
|
dualzahl_ausgeben(output); // Ergebnis ausgeben
|
|
|
|
return 0; // Programm erfolgreich beenden
|
|
}
|
|
|
|
//gcc dualaddi.c fehler.c adturing.c bildschi.c
|