Advertisement
dllbridge

Untitled

Aug 4th, 2024
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.19 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include        <stdio.h>
  5. #include       <stdlib.h>
  6.  
  7.  
  8.  
  9. ////////////////////////////////////////////////////
  10. int main()                                
  11. {
  12.    
  13.     int *p = (int *)malloc(4); 
  14.    
  15.     printf("address p = %d \n", &p);
  16.     printf("        p = %d \n",  p);
  17.    
  18.    *p = 4; 
  19.     printf("       *p = %d \n", *p);  
  20.    
  21.     int &a = *p;
  22.    
  23.     printf("        a = %d \n",  a);    
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. /*
  50. #include       <stdio.h>
  51.  
  52. struct TT
  53. {
  54.     int   x;
  55.     float f;
  56.    
  57. };
  58.  
  59. void foo(struct TT *);
  60.  
  61.  
  62. ////////////////////////////////////////////////////
  63. int main()                                
  64. {
  65.  
  66.     struct TT t;
  67.    
  68.     t.x = 71;
  69.     t.f = 60.2;
  70.    
  71.     printf("old %d\n", t.x);
  72.     printf("weight %.2f\n", t.f);
  73.     foo(&t);
  74.    
  75.     struct TT *p = &t; // ñîçäàþ óêàçàòåëü íå ïåðåìåííóþ t
  76.     int y = (*p).x;    // Ïîëó÷àåì çíà÷åíèå ýëåìåíòà X?
  77.     (*p).x = 72;
  78.     printf("newold %d\n", (*p).x);
  79.     printf("newold %d\n", y);
  80.    
  81.    
  82. }
  83. ////////////////////////////////////////////////////
  84. void foo(struct TT *p)
  85. {
  86.  printf("old %d\n", (*p).x);
  87.  printf("weight %.2f\n", p->f);
  88.  
  89. }
  90.  
  91. */
  92.  
  93.  
  94. /*
  95.     int n = 3;
  96.     printf("value %d\n", n);
  97.     printf("adres %d\n", &n);
  98.     printf("adres %x\n", &n);
  99.     printf("size of = %d", sizeof (float));
  100.    
  101. */
  102.  
  103. /*
  104.  
  105. #include <stdio.h>
  106.  
  107. /////////////////////////////////////////////////////////
  108. struct Dima
  109. {
  110.    
  111.     int   nMin;
  112.     int nHours;
  113.     int  nDays;
  114.    
  115. }t1, t2;
  116.  
  117.  
  118. struct Dima t3, t4;
  119.  
  120. //////////////////////////////////////////////////////////
  121. int main()
  122. {
  123.  
  124.     struct  Dima t5, t6;
  125.    
  126.     t5.nMin = 58;  
  127.    
  128.     struct Dima *p = &t5;
  129.    
  130.     p->nMin = 59;
  131.    
  132.     printf("t5.nMin = %d\n", t5.nMin);
  133. }
  134.  
  135. */
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. /*
  157.  
  158. #include <stdio.h>
  159.  
  160.  
  161.  
  162.  
  163. void foo(int *);
  164.  
  165. //////////////////////////////////////////////////////////
  166. int main()
  167. {
  168.    
  169.    
  170.    
  171.     int nArr[10] = {44, 1, 2, 3, 4, 55, 6, 7, 8, 9};
  172.     foo(nArr);
  173. }
  174.  
  175.  
  176. //////////////////////////////////////////////////////////
  177. void foo(int *p)
  178. {
  179.    
  180.     for(int i = 0; i < 10; i++)
  181.     {
  182.        
  183.         printf("nArr[%d] = %2d \n", i, p[i]);  
  184.        
  185.     }
  186.        
  187. }
  188.  
  189. */
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. /*
  202.  
  203. #include <stdio.h>
  204.  
  205.  
  206.  
  207. char sz[99]  = "nArr   = %d \n";
  208.  
  209. //////////////////////////////////////////////////////////
  210. int main()
  211. {
  212.    
  213.    
  214.    
  215.     printf("sz[1] = %c \n", sz[1]);
  216.    
  217.    
  218. }
  219.  
  220.  
  221. */
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237. /*
  238.  
  239. #include <stdio.h>
  240.  
  241.  
  242. int nArr[10] = {44, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  243.  
  244. char sz[99]  = "nArr   = %d \n";
  245.  
  246. //////////////////////////////////////////////////////////
  247. int main()
  248. {
  249.    
  250.    
  251.     printf(sz,  nArr   );
  252.     printf("nArr   = %d \n", &nArr[0]);
  253.     printf("nArr   = %d \n", &nArr[1]);
  254.     printf("printf = %d \n", printf  );
  255.    
  256.    
  257.     printf("size of sz = %d \n", sizeof(sz) );
  258.    
  259. }
  260.  
  261. */
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286. /*
  287.  
  288. #include <stdio.h>
  289.  
  290.  
  291. int nArr[10] = {44, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  292.  
  293. //////////////////////////////////////////////////////////
  294. int main()
  295. {
  296.    
  297.     int *p = &nArr[4];
  298.    
  299.    
  300.     printf("&nArr[4] = %d \n",  p      );
  301.     printf("&nArr[4] = %d \n", &nArr[4]);  
  302.     printf("&nArr[5] = %d \n", &nArr[5]);  
  303.     printf("&nArr[5] = %d \n",  p + 1  );  
  304.     printf("&nArr[5] = %d \n", &p[1]    );     
  305.     printf("&nArr[5] = %d \n",  p[1]    );     
  306. }
  307.  
  308.  
  309. */
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333. /*
  334. #include <stdio.h>
  335.  
  336.  
  337. int n = 44;
  338.  
  339. //////////////////////////////////////////////////////////
  340. int main()
  341. {
  342.    
  343.     printf("address of n = %d \n", &n);
  344.    
  345.     int *p = &n;
  346.    
  347.     printf("address of n = %d \n",  p);
  348.     printf("address of p = %d \n", &p);
  349. }
  350.  
  351.  
  352. */
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375. /*
  376.  
  377. #include <stdio.h>
  378.  
  379.  
  380. //////////////////////////////////////////////////////////
  381. void foo(char *c)                                       //
  382. {
  383.   //  printf("adress nArr = %s\n", c);
  384.  
  385.       char cBuf = c[0];
  386.      
  387.       c[0] = c[3];  
  388.       c[3] = cBuf;
  389.      
  390.       cBuf = c[1];
  391.       c[1] = c[2];
  392.       c[2] = cBuf;
  393.  
  394. }
  395.  
  396.  
  397.  
  398. //////////////////////////////////////////////////////////
  399. int main()
  400. {
  401.     char  nArr[6] = "SONY";
  402.    
  403.  
  404.    
  405.     foo(nArr);
  406.        
  407.     printf("nArr = %s\n", nArr);
  408.    
  409.  
  410. }    
  411.  
  412. */
  413.  
  414.  
  415.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement