A structure pointer is defined of the type time. With 3 fields min, sec hours having pointers to integers.Write the way to initialize the 2nd element to 10.

QUESTION 8
In the above question an array of pointers is declared.
Write the statement to initialize the 3rd element of the 2 element to 10;

Showing Answers 1 - 9 of 9 Answers

I think this might help

struct time
{
        int* hr;
        int* min;
        int* sec;
};

int main()
{
        struct time t1,*t2;
        int hr=2;
        int min=10;
        int sec=45;


        t1.min= &min;
        t2->min=&min;

        printf("%d %dn",*t1.min,*t2->min);
        return 1;
}

  Was this answer useful?  Yes

I hope, it 'll help you

#include<stdio.h>
#include<malloc.h>
struct timehs
{
int *min,*hrs,*sec;
}*sp;
int main()
{
sp=(struct timehs*)malloc(sizeof(struct timehs));
sp->min=(int *)malloc(sizeof(int));
*(sp->min)=10;
printf("%d",*(sp->min));
return 0;
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions