Advertisement
dllbridge

Untitled

Aug 5th, 2024
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.89 KB | None | 0 0
  1. #include   <stdio.h>
  2. #include  <string.h>
  3.  
  4. int strlent_test(const char* y);
  5.  
  6. ////////////////////////////
  7. int main()                //
  8. {
  9.    char str[99] = "SONY Pictures 2";
  10.    
  11.    
  12.    int n = strlent_test(str);
  13.    
  14.    printf("n = %d", n);
  15.  
  16. return 0;
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. ///////////////////////////////////
  26. int strlent_test(const char* y)  //
  27. {
  28.  
  29.   int i = 0;
  30.  
  31.   while( y[++i] != 0);
  32.  
  33.  
  34. return i;
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. /*
  43. ///////////////////////////////////
  44. int strlent_test(const char* y)  //
  45. {
  46.  
  47.   int n = 0;
  48.  
  49.   while(*y != 0)
  50.   {
  51.      y++;
  52.      n++;
  53.   }
  54.  
  55. return n;
  56. }
  57. */
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. /*
  68. #include <stdio.h>
  69.  
  70.  
  71. void foo(char *p);
  72.  
  73. /////////////////////////////////////////////////////////
  74. int main()
  75. {
  76.    
  77.    
  78.     char sz[5] = "SONY";
  79.    
  80.     char *p = &sz[3];
  81.    
  82.     foo(p);
  83. }
  84.  
  85.  
  86. ////////////////////////////////////////////////////////
  87. void foo(char *p2)
  88. {
  89.  
  90.    
  91.     for(int i = 4; i > 0; i--)
  92.     {
  93.        
  94.         printf("%c", *p2);
  95.                       p2--;
  96.     }
  97.    
  98. }
  99.  
  100. */
  101.  
  102. /*
  103. #include <stdio.h>
  104.  
  105.  
  106. void foo(char *p);
  107.  
  108. /////////////////////////////////////////////////////////
  109. int main()
  110. {
  111.    
  112.    
  113.     char sz[5] = "SONY";
  114.    
  115.     char *p = &sz[3];
  116.    
  117.     foo(p);
  118. }
  119.  
  120.  
  121. ////////////////////////////////////////////////////////
  122. void foo(char *p2)
  123. {
  124.  
  125.    
  126.     for(int i = 4; i > 0; i--)
  127.     {
  128.        
  129.         printf("%c", *(p2-3));
  130.     }
  131.    
  132. }
  133.  
  134.  
  135. */
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.    
  144.     // printf("%s \n", p2-1);
  145.  
  146.  
  147.  
  148.  
  149. //        printf("%c\n", *p);
  150.  //   printf("%c\n", p[2]);
  151.  //   printf(" p= %s\n", p);
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. /*
  166.  
  167. #include <stdio.h>
  168.  
  169.  
  170. char sz[5] = "SONY";
  171.  
  172. ///////////////////////////////////////////////////////
  173. int main()                                           //
  174. {
  175.  
  176.     char *p = &sz[1];
  177.    
  178.     printf("%c\n", *p);
  179.    
  180.     printf("%s \n", &p[-1]);
  181.     printf("%s \n",  p -1 );    
  182.     //printf("%c\n", p[1]);
  183.     //printf(" p= %s\n", p);
  184. }
  185.  
  186. */
  187.  
  188.  
  189.  
  190.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement