Advertisement
dmilicev

test1.c

Jan 10th, 2020
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. /*
  2.  
  3.     test1.c
  4.  
  5.  
  6.     You can find all my C programs at Dragan Milicev's pastebin:
  7.  
  8.     https://pastebin.com/u/dmilicev
  9.  
  10.     https://www.facebook.com/dmilicev
  11.  
  12. */
  13.  
  14. #include <stdio.h>
  15.  
  16. int *test()
  17. {
  18.     int i;
  19.     static int x[4];
  20.  
  21.     for( i=0; i<4; i++ )
  22.     {
  23.         x[i]=i;
  24.     }
  25.  
  26.     return x;
  27. }
  28.  
  29. int *test1()
  30. {
  31.     int i;
  32.     static int x[4];
  33.  
  34.     for( i=0; i<4; i++ )
  35.     {
  36.         x[i]=i%2;
  37.     }
  38.  
  39.     return x;
  40. }
  41.  
  42. int main(void)
  43. {
  44.     int i;
  45.     int *arr = test();
  46.  
  47.     printf("\n test() \n");
  48.  
  49.     for( i=0; i<4; i++ )
  50.     {
  51.         printf("\n arr[%d] = %d \n", i, *(arr+i));
  52.     }
  53.  
  54.     arr = test1();
  55.  
  56.     printf("\n test1() \n");
  57.  
  58.     for( i=0; i<4; i++ )
  59.     {
  60.         printf("\n arr[%d] = %d \n", i, *(arr+i));
  61.     }
  62.  
  63.     return 0;
  64.  
  65. } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement