Advertisement
dllbridge

Untitled

Oct 9th, 2024
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace  std;
  5.  
  6.  
  7. //////////////////////////////////////
  8. void foo(char* p)
  9. {
  10.    // for (int i = 0; i < 5; i++)
  11.    // {
  12.  
  13.         cout << p;
  14.  
  15.     //}
  16. }
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. /////////////////////////////////////////////
  25. int main()
  26. {
  27.  
  28.     char nArr[10] = "SONY";
  29.     foo(nArr);
  30.  
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. /*
  49. #include <stdio.h>
  50.  
  51.  char*  foo1();
  52.  char*  foo2();
  53.  
  54.  
  55. ////////////////////////////////////////////////////
  56. int main()
  57. {
  58.    
  59.     char *p  = foo1();
  60.     char *p2 = foo2();
  61.    
  62.     printf("%c \n", p[-2]);
  63.    
  64.     printf("%s %s \n", &p[-3], p2);
  65.     printf("%s %s \n", foo1(), foo2() );    
  66. }
  67.  
  68.  ///////////////////////////////////////////////////
  69.  char*  foo1()
  70.  {
  71.        static char nArr[15] = "SONY";
  72.        
  73.  return &nArr[3];      
  74.  }
  75.  
  76.  
  77.  
  78. ////////////////////////////////////////////////////
  79. char*  foo2()
  80. {
  81.       static char nArr[15]= "Pictures";
  82.      
  83.  return nArr;      
  84. }
  85.      
  86.      
  87.       */
  88.      
  89.      
  90.      
  91.      
  92.      
  93.      
  94. /*
  95. #include <stdio.h>
  96.  
  97.  void  foo(char*p);
  98.  void foo1(char*p);
  99.  
  100.  
  101.  //////////////////////////////////////////////
  102. int main()
  103. {
  104.    
  105.     char nArr [ 5] =      "SONY";
  106.     char nArr1[10] = " Pictures";
  107.    
  108.     foo ( nArr);
  109.     foo1(nArr1);
  110. }
  111.  
  112.  //////////////////////////////////////////////
  113.  void  foo(char* p)
  114.  {
  115.     // for(int i=0;i<5;i++)
  116.     // {
  117.          printf("%s",p);
  118.     // }
  119.  }
  120.  
  121.  void foo1(char*p)
  122.  
  123.  {
  124.     // for(int i=0;i<9;i++)
  125.     // {
  126.          printf("%s",p);
  127.     // }
  128.      
  129.  }
  130.  
  131.  
  132. */
  133.  
  134.  
  135.  
  136.  
  137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement