monoteen

1103_array_function_Struct

Nov 2nd, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define MAX_SIZE 6
  5.  
  6. struct point {
  7.     int x;
  8.     int y;
  9. };
  10.  
  11. int PrintArray(int *arr, int size);
  12. int PrintPoint(struct point pt);
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16.     int arri[MAX_SIZE] = {10, 20, 30, 40, 50, 0};
  17.    
  18.     struct point pt;
  19.    
  20.     pt.x = 10;
  21.     pt.y = 20;
  22.    
  23.     PrintPoint(pt);
  24.    
  25.     PrintArray(arri, MAX_SIZE);
  26.     PrintArray(arri, 3);
  27.    
  28.     pt.x = 100;
  29.     pt.y = 200;
  30.     PrintPoint(pt);
  31.    
  32.     //System("PAUSE");
  33.    
  34.     return 0;
  35. }
  36. int PrintArray(int *arr, int size)
  37. {
  38.     int i;
  39.    
  40.     for(i=0; i<size; i++)
  41.     {
  42.         printf("Arri[%d] = %d\n", i, arr[i]);
  43.     }
  44.    
  45.     return 0;
  46. }
  47. int PrintPoint(struct point pt) {
  48.     printf("Point x = %d, y = %d\n", pt.x, pt.y);
  49.    
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment