Advertisement
dllbridge

Untitled

Oct 13th, 2023
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.33 KB | None | 0 0
  1.  
  2. #include    <stdio.h>
  3. #include   <string.h>
  4.  
  5. ////////////////////////////////  struct
  6. class CMonth
  7. {
  8.    
  9.    
  10.    
  11.    
  12.    
  13.     public:
  14.    
  15.     char sz[19];
  16.     int   nDays;
  17.    
  18.     //////////////////
  19.     void foo()
  20.     {
  21.         nDays = 1130;
  22.        
  23.     }
  24.    
  25.    
  26.     ///////////////////
  27.     char* foo2();
  28.    
  29. };
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. ////////////////////////////////////////////////////
  37. int main()                                        //
  38. {
  39.  
  40.  
  41.     CMonth Cn;
  42.    
  43.     Cn.foo ();
  44.     Cn.foo2();
  45.     //foo2()
  46.     printf("%s nDays = %d\n", Cn.sz, Cn.nDays);
  47.  
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54.     char* CMonth::foo2()
  55.     {
  56.        
  57.         strcpy(sz, "May");
  58.        
  59.        
  60.         return sz;
  61.     }  
  62.  
  63.  
  64.  
  65.  
  66. /*
  67. #include   <stdio.h>
  68.  
  69.  
  70. ////////////////////////////////  struct
  71. class CMonth
  72. {
  73.    
  74.    
  75.     char sz[19];
  76.    
  77.    
  78.     public:
  79.    
  80.    
  81.     int   nDays;
  82.    
  83.    
  84.     void foo()
  85.     {
  86.         nDays = 1130;
  87.        
  88.     }
  89.    
  90. };
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. ////////////////////////////////////////////////////
  98. int main()                                        //
  99. {
  100.  
  101.  
  102.     CMonth Cn;
  103.    
  104.     Cn.foo();
  105.    
  106.     printf("nDays = %d\n", Cn.nDays);
  107.  
  108. }
  109.  
  110.  
  111.  
  112.  
  113. */
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. /*
  130.  
  131. #include   <stdio.h>
  132.  
  133.  
  134. ////////////////////////////////
  135. struct CMonth
  136. {
  137.     char sz[19];
  138.     int   nDays;
  139.    
  140. };
  141.  
  142.  
  143. void foo(CMonth *p);
  144.  
  145.  
  146.  
  147. ////////////////////////////////////////////////////
  148. int main()                                        //
  149. {
  150.  
  151.     CMonth mArr[14];
  152.  
  153.     foo(mArr);
  154.    
  155.     printf("January  = %d\n", mArr[1].nDays);
  156.     printf("February = %d\n", mArr[2].nDays);
  157.     printf("March    = %d\n", mArr[3].nDays);
  158. }
  159.  
  160.  
  161.  
  162. ////////////////////////////////////////////////////
  163. void foo(CMonth *p)
  164. {
  165.    
  166.      p = p + 1;             //[1].nDays = 11131;
  167.    
  168.      CMonth &a = *p;
  169.      
  170.      a.nDays = 4444;
  171.      //--------------
  172.      
  173.       p += 1;
  174.      
  175.       p->nDays = 29;
  176.      //--------------
  177.       p ++;
  178.      
  179.      
  180.      (*p).nDays = 31;
  181. }
  182.  
  183. */
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. /*
  206.  
  207.  
  208. #include   <stdio.h>
  209.  
  210.  
  211. ////////////////////////////////
  212. struct CMonth
  213. {
  214.     char sz[19];
  215.     int   nDays;
  216.    
  217. };
  218.  
  219.  
  220. void foo(CMonth *p);
  221.  
  222.  
  223.  
  224. ////////////////////////////////////////////////////
  225. int main()                                        //
  226. {
  227.  
  228.     CMonth mArr[14];
  229.  
  230.     foo(mArr);
  231.    
  232.     printf("%d\n", mArr[1].nDays);
  233.  
  234. }
  235.  
  236.  
  237.  
  238. ////////////////////////////////////////////////////
  239. void foo(CMonth *p)
  240. {
  241.    
  242.      p[1].nDays = 11131;
  243.    
  244. }
  245.  
  246.  
  247. */
  248.  
  249.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement