This commit is contained in:
parent
f71cd26460
commit
3b6c8ce2f4
|
@ -0,0 +1,16 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int* i = (int*)malloc(sizeof(int));
|
||||
*i = 42;
|
||||
|
||||
double* d = (double*)malloc(sizeof(double));
|
||||
*d = *i;
|
||||
|
||||
free(i);
|
||||
i = NULL;
|
||||
|
||||
free(d);
|
||||
d = NULL;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct angestellter {
|
||||
char name[41];
|
||||
struct angestellter* chef;
|
||||
};
|
||||
|
||||
typedef struct angestellter angestellter;
|
||||
|
||||
int main(void) {
|
||||
angestellter asterix = { "Asterix", NULL };
|
||||
angestellter majestix = { "Majestix", NULL };
|
||||
angestellter* obelix;
|
||||
|
||||
obelix = (angestellter*)malloc(sizeof(angestellter));
|
||||
|
||||
strcpy(obelix->name, "Obelix");
|
||||
|
||||
asterix.chef = &majestix;
|
||||
obelix->chef = &majestix;
|
||||
majestix.chef = &asterix;
|
||||
|
||||
free(obelix);
|
||||
obelix = NULL;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct angestellter {
|
||||
char name[41];
|
||||
struct angestellter* chef;
|
||||
struct angestellter* bestie;
|
||||
};
|
||||
|
||||
typedef struct angestellter angestellter;
|
||||
|
||||
int main(void) {
|
||||
angestellter asterix = { "Asterix", NULL, NULL };
|
||||
angestellter majestix = { "Majestix", NULL, NULL };
|
||||
angestellter* obelix;
|
||||
|
||||
obelix = (angestellter*)malloc(sizeof(angestellter));
|
||||
|
||||
strcpy(obelix->name, "Obelix");
|
||||
|
||||
asterix.chef = &majestix;
|
||||
obelix->chef = &majestix;
|
||||
|
||||
asterix.bestie = obelix;
|
||||
obelix->bestie = &asterix;
|
||||
|
||||
free(obelix);
|
||||
obelix = NULL;
|
||||
}
|
Loading…
Reference in New Issue