Now i wanna remove them like this (timer runs 19 times):
- Code: Select all
char *tma;
sprintf(tma, "black.%i", no);
no++;
DestroyActor(tma);
it just crashes GE. what did i wrong?
Why doesn´t this work?
char *tma;
sprintf(tma, "black.%i", no);
no++;
DestroyActor(tma);
char* tma = malloc(255);
skydereign wrote:Yeah, the problem with using a char* like that is that you haven't allocated memory for it. So essentially, you created a pointer that doesn't point to anything. As you found out, gE reacts when you try to write to it by crashing. In future if you want to use a char* instead of a char[], you can use this.
- Code: Select all
char* tma = malloc(255);
char[]s already have memory allocated for them, while pointers only have an address.
void Jump(char * name, int number, int power)
{
Actor * actor = getclone(name);
if (jump[number] == 0)
{
actor->yvelocity = - power;
jump[number] = 1;
}
}
char* string = "0000000000";
Users browsing this forum: No registered users and 1 guest