Page 1 of 1

Function that Returns a String

PostPosted: Mon Aug 08, 2005 2:28 am
by jazz_e_bob
I need an example of a function that returns a string. :?

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) );

PostPosted: Mon Aug 08, 2005 8:30 pm
by makslane
Use:

char *stateName( int stateID )

PostPosted: Mon Aug 08, 2005 9:39 pm
by jazz_e_bob
Thanks mate.

GE Rocks!