Guest User

Untitled

a guest
Jun 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. float* copy_tab( float tab[], int size)
  5. {
  6. float *ptr = malloc(sizeof(tab));
  7. int i = 0;
  8. for(i=0 ; i<size ; i++)
  9. {
  10. ptr[i] = tab[i];
  11. }
  12. return ptr;
  13. }
  14.  
  15. float tab[] = {3.2 , 5.1 , 7.8};
  16. int size = 3;
  17.  
  18. int main(int argc, char *argv[]) {
  19. float *ptr = copy_tab(tab,size);
  20. printf("%f , %f , %f", ptr[0], ptr[1], ptr[2]);
  21. free(ptr);
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment