fork download
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. uint8_t array[] = {8, 2, 3, 1, 7};
  6. uint8_t *a;
  7.  
  8. void test(uint8_t **ptr, uint8_t *length)
  9. {
  10. a = array;
  11. *ptr = a;
  12. *length = sizeof(array);
  13. }
  14.  
  15. int main() {
  16. // your code goes here
  17.  
  18. uint8_t *p = NULL;
  19. uint8_t length;
  20. uint8_t temp[5];
  21.  
  22. test(&p, &length);
  23. memcpy(temp, p, length);
  24. for (int i = 0; i < length; i++) {
  25. printf("%d\t", temp[i]);
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
8	2	3	1	7