M
manish sahu
#include<stdio.h>
#include<conio.h>
int main()
{
struct phone
{
long int city_code;
long int ph_no;
}ph;
struct person
{
char name[15];
char address[20];
struct phone ph;
};
struct person p={"abcdefg","swsw",12345,23432340};
struct person *ptr;
ptr=&p;
printf("\n %s %s %ld %ld",(*ptr).name,(*ptr).address,
(*ptr).ph.city_code,(*ptr).ph.ph_no);
printf("\n %s %s %ld %ld ",ptr->name,ptr->address,ptr-
This is my program here i am accessing the
struct person with a structure pointer ptr
and for accessing the members of phone structure i am using ph
variable of phone structure type(Defined inside struct person)
What I have to do is that
instead of taking variable ph of type struct phone
i want to use a phone structure pointer.
like
struct phone *p1;
and after that i want to access the members of struct person and
member of struct phone with a struct person pointer
struct person *ptr.
Plz tell me HOw to access
ThankYou
#include<conio.h>
int main()
{
struct phone
{
long int city_code;
long int ph_no;
}ph;
struct person
{
char name[15];
char address[20];
struct phone ph;
};
struct person p={"abcdefg","swsw",12345,23432340};
struct person *ptr;
ptr=&p;
printf("\n %s %s %ld %ld",(*ptr).name,(*ptr).address,
(*ptr).ph.city_code,(*ptr).ph.ph_no);
printf("\n %s %s %ld %ld ",ptr->name,ptr->address,ptr-
}ph.city_code,ptr->ph.ph_no);
This is my program here i am accessing the
struct person with a structure pointer ptr
and for accessing the members of phone structure i am using ph
variable of phone structure type(Defined inside struct person)
What I have to do is that
instead of taking variable ph of type struct phone
i want to use a phone structure pointer.
like
struct phone *p1;
and after that i want to access the members of struct person and
member of struct phone with a struct person pointer
struct person *ptr.
Plz tell me HOw to access
ThankYou