1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
void combat(const char* atakfuncion)
{
const size_t N = 10;
void ( *pf[N] )() =
{
atakmonster1, atakmonster2, atakmonster3, atakmonster4,
atakmonster5, atakmonster6, atakmonster7, atakmonster8,
atakmonster9, atakmonster10
};
const char * fnames[N] =
{
"atakmonster1", "atakmonster2", "atakmonster3", "atakmonster4",
"atakmonster5", "atakmonster6", "atakmonster7", "atakmonster8",
"atakmonster9", "atakmonster10"
};
/*
const char **p = std::find_if( std::begin( fnames ), std::end( fnames ),
[=]( const char *s )
{
return ( std::strcmp( s, atakfuncion ) == 0 );
} );
*/
size_t i = 0;
while ( i < N && std::strcmp( fnames[i], atakfuncion ) != 0 ) ++i;
if ( i != N ) pf[i];
}
|