34 lines
744 B
C
34 lines
744 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
// Funktionsprototypen
|
|
void fehlerausgabe(const char *msg);
|
|
void dualzahl_einlesen(char *buffer, int maxlen);
|
|
void dualzahl_ausgeben(const char *buffer);
|
|
void dual_addiere_eins(const char *input, char *output, int maxlen);
|
|
|
|
#define MAXLEN 65
|
|
|
|
int main() {
|
|
char input[MAXLEN];
|
|
char output[MAXLEN];
|
|
|
|
dualzahl_einlesen(input, MAXLEN);
|
|
|
|
// Eingabe prüfen
|
|
for (int i = 0; input[i]; ++i) {
|
|
if (input[i] != '0' && input[i] != '1') {
|
|
fehlerausgabe("Nur 0 und 1 erlaubt!");
|
|
}
|
|
}
|
|
|
|
dual_addiere_eins(input, output, MAXLEN);
|
|
|
|
if (output[0] == '\0') {
|
|
fehlerausgabe("Fehler bei der Addition!");
|
|
}
|
|
|
|
dualzahl_ausgeben(output);
|
|
|
|
return 0;
|
|
} |