Advertisement
horselurrver

Offset

Aug 4th, 2016
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void copy_ptr(double source[], double target1[], int num, int offset);
  4.  
  5. int main(void){
  6.     int i;
  7.     double array[7]={1,2,3,4,5,6,7};
  8.     double array2[3];
  9.     copy_ptr(array, array2, 3, 4);
  10.    
  11.     for(i=0; i<3; i++)
  12.         printf("%f\n", array2[i]);
  13.     return 0;
  14. }
  15.  
  16.  
  17. void copy_ptr(double source[], double target1[], int num, int offset){
  18.     int i;
  19.     double *ptr = (source+offset);
  20.     double *ptr2=target1;
  21.     for(i=0; i<num; i++){
  22.         *ptr2=*ptr;
  23.         ptr2++;
  24.         ptr++;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement