Advertisement
horselurrver

VLA

Aug 4th, 2016
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. void copy(int n, int m, double source[n][m]);
  3. void print_array(int n, int m, double target[n][m]);
  4.  
  5. double array[3][5]={{1,2,3,4,5},{6,7,8,9,12},{15,16,17,18,19}};
  6. double target[3][5];
  7.  
  8. int main(void){
  9.     copy(3,5, array);
  10.     print_array(3,5,target);
  11.     return 0;
  12. }
  13.  
  14. void copy(int n, int m, double source[n][m]){
  15.     int rows, cols;
  16.     for(rows=0; rows<n; rows++){
  17.         for(cols=0; cols<m; cols++){
  18.             target[rows][cols]=source[rows][cols];
  19.         }
  20.     }
  21.    
  22.  
  23. }
  24.  
  25. void print_array(int n, int m, double target[n][m]){
  26.     int rows, cols;
  27.     for(rows=0; rows<n; rows++){
  28.         for(cols=0; cols<m; cols++){
  29.             printf("%.1f  ", target[rows][cols]);
  30.         }
  31.         printf("\n");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement