Advertisement
dllbridge

Untitled

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