commit b693bae6e0f5108cab1f627958314d9dc982dbd6 Author: f0tt3r Date: Mon Jun 8 20:27:18 2026 +0200 aufgabe1 ohne ein paar punkte diff --git a/hallo b/hallo new file mode 100755 index 0000000..ad1cb68 Binary files /dev/null and b/hallo differ diff --git a/hallo-welt.c b/hallo-welt.c new file mode 100644 index 0000000..3b48aa9 --- /dev/null +++ b/hallo-welt.c @@ -0,0 +1,34 @@ +#include "hallo-welt.h" +#include +#include +#include + +#ifndef HALLO +#define HALLO "Hallo Welt" +#endif + +void hallo_welt(void) { printf(HALLO); } + +// use more then one int type +const char *binaerzahl(uint8_t bin) { + char *str = malloc(sizeof(bin) * 8 + + 1); // Allocate 8 bits for actual data and 1 Bit for the \0 + // sign indicating the end of the string + if (!str) + return NULL; + uint8_t bb; + printf("sizeof(bin) = %lu\n", sizeof(bin) * 8); + for (int i = sizeof(bin) * 8 - 1; i >= 0; i--) { + bb = bin >> i; + str[i] = (bb % 2 == 1) ? 1 : 0; + printf("%d", str[i]); + } + str[sizeof(bin)] = '\0'; + return str; +} + +int main(void) { + // hallo_welt(); + char *in; + printf(binaerzahl(8)); +} diff --git a/hallo-welt.h b/hallo-welt.h new file mode 100644 index 0000000..d6cf148 --- /dev/null +++ b/hallo-welt.h @@ -0,0 +1,7 @@ +#include + +#ifndef HALLO +#define HALLO "Hallo Welt!" +#else +printf("HALLO ist schon definiert!"); +#endif