Advertisement
Nickpips

mem.c0

Dec 3rd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #use <conio>
  2.  
  3. void pnt(int a) {
  4. printint(a);
  5. println("");
  6. }
  7.  
  8. struct k {
  9. int a;
  10. int* b;
  11. int** c;
  12. };
  13.  
  14. struct st {
  15. int* a;
  16. int b;
  17. struct k sk;
  18. string c;
  19. char d;
  20. char* e;
  21. int** f;
  22. };
  23.  
  24. void pntarr(int[] arr, int len)
  25. //@requires \length(arr) == len;
  26. {
  27. for( int i = 0; i < len; i++ )
  28. pnt(arr[i]);
  29. }
  30.  
  31. int main() {
  32. int v0 = 2;
  33. int* v1 = alloc(int);
  34. int[] v2 = alloc_array(int, 5);
  35. int*[] v3 = alloc_array(int*, 5);
  36. char[] v4 = alloc_array(char, 2);
  37. *v1 = 5;
  38. v2[2] = *v1;
  39. v2[0] = 4;
  40. v3[0] = v1;
  41. v3[1] = alloc(int);
  42. *(v3[1]) = 2;
  43. v3[2] = v1;
  44.  
  45. v4[0] = 'a';
  46. v4[1] = 'k';
  47.  
  48. struct st* s = alloc(struct st);
  49. s->a = v1;
  50. s->b = *(v3[1]);
  51. s->sk.a = 0;
  52. s->sk.c = alloc(int*);
  53. *(s->sk.c) = v1;
  54. s->sk.b = v3[0];
  55. s->c = "hello\n";
  56. s->d = v4[1];
  57. s->e = alloc(char);
  58. *(s->e) = v4[1];
  59. s->f = s->sk.c;
  60.  
  61. pnt(v0);
  62. pnt(*v1);
  63. pntarr(v2, 5);
  64. for( int i = 0; i < 5; i++ ) {
  65. if( v3[i] == NULL )
  66. print("NULL\n");
  67. else
  68. pnt(*(v3[i]));
  69. }
  70. for( int i = 0; i < 2; i++ ) {
  71. printchar(v4[i]);
  72. }
  73. pnt(*(s->a));
  74. pnt(s->b);
  75. pnt(s->sk.a);
  76. pnt(*(s->sk.b));
  77. pnt(**(s->sk.c));
  78. print(s->c);
  79. printchar(s->d);
  80. println("");
  81. printchar(*(s->e));
  82. println("");
  83. printint(**(s->f));
  84. println("");
  85.  
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement