mardi 10 août 2021

Why do uint8_t arrays behave different to uint16_t array when using begin() and end()?

I am trying to understand why the following code snippet behaves different for the uint16_t array than the uint8_t array. I would expect memory addresses to be printed for both cases. What am I missing?

#include <iostream>

int main()
{
    uint16_t a[3] = { 65, 66, 67 };
    uint8_t b[3] = { 88, 89, 90 };
    
    std::cout << std::begin(a) << " " << std::end(a) << std::endl;
    std::cout << std::begin(b) << " " << std::end(b) << std::endl;
}

Sample output:

0x7ffee64ca990 0x7ffee64ca996
XYZ 

Aucun commentaire:

Enregistrer un commentaire