Hi,
please see the below code.

Code:
struct kk
{
    char a;
    char name[10];
};


int main()
{
    char* getname(struct kk *,char *);
    struct kk p;
    char *ret = NULL;
    p.a =0;
    strcpy(p.name,"hai");
    ret = getname(&p,"name");
    printf("result : %s",ret);
    return 0;
}


void getname(struct kk *ptr,char *string)
{
    char *result;
    result=(char *)malloc(10);
    strcpy(result,    );--->what can i put?
    printf("%s",result);

}
here getname is a function takes structure pointer, member name as inputs .
purpose of function is to print the value of passed structure member.

in getname function ,

strcpy(result, );------ what can i put here as second argument to access the structure member "name".

is strcpy(result,ptr->string) right one? or strcpy(result,ptr->*string) right one?

i want to print the string result which is equal to "hai".

Could you please help me regarding this?

Thanks in advance,
Srinu.






~