I would like to access a member within a struct by using the value of a string:
struct hello_world
{
char rate;
char ssid;
};
There is a varibale let's say
char *string="ssid";
I would like to use the value of this string to refer to the ssid
member within the hello_world
struct. Is this possible?
Nope, it's not.
You need a (long) if-else
statement, that will do this. Like:
struct hello_world hw;
char *string="ssid";
if( 0 == strcmp( "ssid", string ) )
{
// use hw.ssid
}
else if ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With