I have a struct containing several members and I need to initialize them from text file. The text file contains values for all members in my struct using the same names. Is there away, to go over all members in the struct and refer to variable name as a string for comparison?
for example:
typedef struct pra_gen_con_file {
int num_of_tasks;
char vsr_id[1000];
} pra_gen_con_file_t;
And in text config file I have:
num_of_tasks = 5
vsr_id = lior
I need something like this:
for line in text_file_lines:
for member in pra_gen_con_file.members():
if member.member_name == line.split('=')[0]:
pra_gen_con_file.member = line.split('=')[1]
I need to implement in C.
Thanks Lior