added ws202425 courses

This commit is contained in:
2024-11-14 13:11:04 +01:00
parent 800282c2e8
commit beb31897b1
461 changed files with 20368 additions and 0 deletions
@@ -0,0 +1,47 @@
/* point_3.c
*
* Datentyp eines zweidimensionalen Punktes
* mit Funktion zum Verschieben
* und dynamischer Speicherverwaltung
*/
#include <stdio.h>
#include <stdlib.h>
struct point {
float x;
float y;
};
void move(struct point * punkt, float dx, float dy) {
punkt->x += dx;
punkt->y += dy;
}
int main() {
struct point * ptr;
ptr = malloc(sizeof(struct point)); // impl. Typcast des Pointers
if (ptr != NULL) {
ptr->x = 10;
ptr->y = 20;
printf("\nx-Koordinate von p: %f", ptr->x);
printf("\ny-Koordinate von p: %f", ptr->y);
free(ptr);
printf("\n");
printf("\nnach free():");
// Dangling Pointer!
printf("\nx-Koordinate von p: %f", ptr->x);
printf("\ny-Koordinate von p: %f", ptr->y);
printf("\n\n");
}
return 0;
}