declaring a string
Posted: Wed Dec 07, 2011 9:03 pm
i feel like im declaring a string wrong, because when i run this function, my game freezes and crashes. Here is the code for the function i made.
Im declaring a string like this:
what is the correct way to do it?
- Code: Select all
void p1AnimFinish(int characterNo, int dir, int attackNo)
{
//dir=1 is left, dir=2 is right
//attackNo is whatever the attacks is in the attacks array
char charName;
char animCharName;
char stand;
char crouch;
char fall;
switch(characterNo)
{
case 1:
sprintf(charName, "mario");
sprintf(animCharName, "mario");
break;
}
switch(dir)
{
case 1:
switch(p1OnGround)
{
case 1:
switch(p1Down)
{
case 0:
sprintf(stand, "%s_stand_left", animCharName);
ChangeAnimation(charName, stand, NO_CHANGE);
break;
case 1:
sprintf(crouch, "%s_crouch_left", animCharName);
ChangeAnimation(charName, crouch, NO_CHANGE);
break;
}
break;
case 0:
sprintf(fall, "%s_fall_left", animCharName);
ChangeAnimation(charName, fall, NO_CHANGE);
break;
}
break;
case 2:
switch(p1OnGround)
{
case 1:
switch(p1Down)
{
case 0:
sprintf(stand, "%s_stand_right", animCharName);
ChangeAnimation(charName, stand, NO_CHANGE);
break;
case 1:
sprintf(crouch, "%s_crouch_right", animCharName);
ChangeAnimation(charName, crouch, NO_CHANGE);
break;
}
break;
case 0:
sprintf(fall, "%s_fall_right", animCharName);
ChangeAnimation(charName, fall, NO_CHANGE);
break;
}
break;
}
canDo=1;
attacks[attackNo]=0;
}
Im declaring a string like this:
- Code: Select all
char stringName;
what is the correct way to do it?