#include <stdio.h>
#include <stdlib.h>
struct student{
int wkTime;
} x;
int main(void) {
struct student* john = malloc(sizeof(x));
john ->wkTime = 10;
void* emp;
emp = (char *) "wkTime";
printf("%d",john ->wkTime);
printf("%d",john -> *(emp));
return 1;
}
I would want to access the value of vaiable - wkTime not using john ->wkTime but using *emp I would like to get the value of wkTime variable of john. Essentially in the case where I would be having the variable name in form of a character pointer. I would want to use that to access the variable inside my instance of student node.