Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct el
  6. {
  7.          double d;
  8.          char c;
  9.          int *i;
  10. };
  11.  
  12. int main(void)
  13. {
  14.          struct el *p_struct;
  15.  
  16.          p_struct = (struct el *)malloc(sizeof(struct el));
  17.          if (!p_struct)
  18.                exit(-1);
  19.  
  20.          p_struct->d = 3.1415926525897936264;
  21.          p_struct->c = '\0';
  22.          p_struct->i = (int*)malloc(sizeof(int));
  23.          if (!(p_struct->i))
  24.                  exit(-1);
  25.  
  26.           printf("Struct elements: %lf %c %d", p_struct->d, p_struct->c, *p_struct->i);
  27.  
  28.           free(p_struct);
  29.           return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement