folgender Fehler tritt beim Compilieren meines Codes auf:
"Anfrage nach Element "xPos" in etwas, was keine Struktur oder Variante ist"
Code: Alles auswählen
if((movingObjects=getObjects())!=NULL) value++;
printf("bla: %d",movingObjects[0].xPos);
object.c:
Code: Alles auswählen
...
#include "objects.h"
struct object* createObject(char id, int xPos, int yPos, int healthPoints, int attack, char type){
struct object* newObject = malloc(sizeof(struct object));
newObject->id = id;
newObject->xPos = xPos;
newObject->yPos = yPos;
newObject->healthPoints = healthPoints;
newObject->type = type;
newObject->attack = attack;
return newObject;
}
struct object** getObjects(){
struct object** objects = (struct object**) malloc(50*sizeof(struct object*));
objects[0] = createObject(1,50,50,100,10,0);
return objects;
}
Code: Alles auswählen
struct object{
char id;
int xPos;
int yPos;
int healthPoints;
int attack;
char type;
};
struct object** getObjects();
Code: Alles auswählen
struct object** movingObjects;
Ich bitte um Hilfe, vielen Dank im Vorraus, mit freundlichen Grüßen,
petterapamm