fork download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. uint8_t a1[2][3] =
  7. {
  8. { 1, 2, 3 },
  9. { 4, 5, 6 },
  10. };
  11.  
  12. // copy
  13. uint8_t a2[3];
  14. memcpy( a2, a1[0], 3 );
  15.  
  16. for ( uint8_t i = 0; i < 3; i++ )
  17. {
  18. printf( "a2[%hhu] = %hhu\n", i, a2[i] );
  19. }
  20.  
  21. // or point to
  22. uint8_t * a3 = a1[1];
  23.  
  24. for ( uint8_t i = 0; i < 3; i++ )
  25. {
  26. printf( "a3[%hhu] = %hhu\n", i, a3[i] );
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5472KB
stdin
Standard input is empty
stdout
a2[0] = 1
a2[1] = 2
a2[2] = 3
a3[0] = 4
a3[1] = 5
a3[2] = 6