How to access members of a `struct' according to a value of a string?
c, string, struct
Solution
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 ...
Problem
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?