placeholder version
This commit is contained in:
parent
b693bae6e0
commit
62c0529e16
4 changed files with 18 additions and 41 deletions
BIN
hallo
BIN
hallo
Binary file not shown.
34
hallo-welt.c
34
hallo-welt.c
|
|
@ -1,34 +0,0 @@
|
||||||
#include "hallo-welt.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#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));
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef HALLO
|
|
||||||
#define HALLO "Hallo Welt!"
|
|
||||||
#else
|
|
||||||
printf("HALLO ist schon definiert!");
|
|
||||||
#endif
|
|
||||||
18
hallo_welt.c
Normal file
18
hallo_welt.c
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
//TODO: Hier könnte etwas fehlen...
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int temp;
|
||||||
|
printf("Bitte gib eine Dezimalzahl ein: ");
|
||||||
|
scanf("%d", &temp);
|
||||||
|
binaerzahl(temp); //TODO: ist bis jetzt noch nicht definiert
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Die Funktion soll die eingegebene Zahl als Binärzahl ausgegeben werden
|
||||||
|
* Hierfür sollen Bitwise Operatoren und/oder Bitwise Shift genutzt werden.
|
||||||
|
*/
|
||||||
|
void binaerzahl(int input){
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue