Files
courses/2024_Praxis_der_Programmierung/ue5/point_2.c
T
2024-11-28 11:27:09 +01:00

49 lines
941 B
C

/* point_1.c
*
* Datentyp eines zweidimensionalen Punktes
* verschiedene Methoden der Komponentenselektion
*/
#include <stdio.h>
struct point {
float x;
float y;
};
void move_point(struct point * ptr, float delta_a, float delta_b){
if (ptr != NULL){
ptr->x += delta_a;
ptr->y += delta_b;
}
}
int main() {
struct point p1 = {3.0f,4.0f};
struct point * ptr = &p1;
struct point p2 = {0.0f,0.0f};
printf("\nx-Koordinate von p1: %f", ptr->x);
printf("\ny-Koordinate von p1: %f", ptr->y);
p2 = p1;
printf("\nx-Koordinate von p2: %f", p2.x);
printf("\ny-Koordinate von p2: %f", p2.y);
printf("\nAdresse von p1: %p", (void*)&p1);
printf("\nAdresse von p2: %p", (void*)&p2);
printf("\n\n");
move_point(ptr, 4.0f , 5.0f);
printf("\nx-Koordinate von p1: %f", ptr->x);
printf("\ny-Koordinate von p1: %f", ptr->y);
printf("\n\n");
return 0;
}