Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7. int *ar1 = (int*)malloc(5*sizeof(int));
  8. char *ar2 = (char*)malloc(20*sizeof(char));
  9.  
  10. for(int i = 0; i < 5; i++) ar1[i] = i;
  11.  
  12. memcpy(ar2, ar1, sizeof(5*sizeof(int)));
  13.  
  14. for(int i = 0; i < 5; i++) printf("%d ", ar1[i]);
  15. printf("\n");
  16. for(int i = 0; i < 20; i++) printf("%d ", ar2[i]);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement