...
/Solution Review: Dynamically Allocate Space for Two Structures
Solution Review: Dynamically Allocate Space for Two Structures
Follow the step-by-step instructions to dynamically allocate space for two structures.
We'll cover the following...
Solution
See the code given below!
Press + to interact
#include <stdio.h>#include <stdlib.h>struct Address{char Houseno[ 20 ], Street[30], City[25] ;long int Pincode ;} ;struct Employee{char Name[30] ;int Age ;struct Address add ;float Salary ;} ;int main( ){struct Employee *p2;struct Address *p1;p1 = ( struct Address * ) malloc ( sizeof ( struct Address ) ) ;p2 = ( struct Employee * ) malloc ( sizeof ( struct Employee ) ) ;}
Explanation
p1
and p2
are pointers that are ...