Hallo @ all!!
Brauche dirngend Hilfe bei Structs folgendes!!
Mein Struct:
Da ich mehrere x und y werte habe erstelle ich ein dynamisches array
Und jetzt möchte ich in der funktion meine eingelesen Werte ausgeben:
Aber das funktioniert einfach nicht WARUM NICHT ich komme einfach nicht weiter wäre sehr dankbar wenn mir jemand dabei helfen könnte!!
Brauche dirngend Hilfe bei Structs folgendes!!
Mein Struct:
Code:
typedef struct _Polygon_
{
int *x;
int *y;
}Polygon;
Code:
int main()
{
Polygon pol;
pol.x = malloc(sizeof(int));
pol.x[0]= 10;
pol.x = realloc(pol.x, 3 * sizeof(int));
pol.x[1] = 20;
pol.x[2]= 30;
pol.x[3]= 50;
ausgabe(); => funktion zur ausgabe;
return 0;
}
Code:
ausgabe()
{
Polygon pol;
printf("%d", pol.x[2]);
}