void a()
{
Serial.println( "a" );
}
void b()
{
Serial.println( "b" );
}
void exec( char const * const input )
{
struct function_t
{
char const * const name;
void const (* const pointer)();
};
static const function_t functions[] =
{
{ "a", a },
{ "b", b },
};
bool error = true;
for ( const function_t function : functions )
{
if ( !strcmp( input, function.name ) )
{
function.pointer();
error = false;
break;
}
}
if ( error == true )
{
Serial.println( "error" );
}
}
void setup()
{
Serial.begin( 115200 );
exec( "a" );
exec( "b" );
exec( "c" );
}
void loop()
{
}