Function that Returns a String
Posted: Mon Aug 08, 2005 2:28 am
I need an example of a function that returns a string.
This is the kind of thing I want:
Usage: strcpy ( debug.text, stateName(0) );
This is the kind of thing I want:
- Code: Select all
char stateName( int stateID )
{
char *result;
switch ( stateID )
{
case 0: strcpy ( result, "STANDING" ); break;
case 1: strcpy ( result, "WALKING" ); break;
case 2: strcpy ( result, "RUNNING" ); break;
case 3: strcpy ( result, "DYING" ); break;
}
return result;
}
Usage: strcpy ( debug.text, stateName(0) );