POINTER STRUCTURES EXAMPLE PROGRAM IN C

 #include <stdio.h>  
 #include <stdlib.h>   
 #include <memory.h>  
 struct mystruct {  
      int a;  
 };  
 typedef struct mystruct * pmystruct;  
 pmystruct getpstruct()  
 {  
      pmystruct temp=(pmystruct)malloc(sizeof(pmystruct*));  
      return temp;  
 }  
 int main(int argc, char* argv[])  
 {    
      int * fred;  
      pmystruct b= getpstruct();  
      b->a = 8;  
      ++b->a;  
      printf ("The value of b->a is %i \n",b->a);  
      free(b);  
      fred = (int *) malloc(sizeof(int));  
      memset(fred,0x100,sizeof(int));  
      printf("Value of *fred = %i\n",*fred);  
      free(fred);  
      return 0;  
 }  

Post a Comment

0 Comments