fork download
  1. #include <stdio.h>
  2.  
  3. #include <string.h>
  4.  
  5. #include <errno.h>
  6. int main()
  7. {
  8. int a1[10], a2[100], i;
  9. int err =0 ;
  10. // Populate a2 with squares of integers
  11. for (i = 0; i < 100; i++)
  12. {
  13. a2[i] = i*i;
  14. }
  15. // Tell memcpy_s to copy 10 ints (40 bytes), giving
  16. // the size of the a1 array (also 40 bytes).
  17. err = memcpy(a1, a2, 10 * sizeof (int) );
  18. if (!err)
  19. {
  20. printf("Error executing memcpy_s.\n");
  21. }
  22. else
  23. {
  24. for (i = 0; i < 10; i++)
  25. printf("%d ", a1[i]);
  26. }
  27. printf("\n");
  28. }
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
0 1 4 9 16 25 36 49 64 81