Thanks, but what confused me is what the size of the array has with the stuff??? |
Arrays, as inherited from the C language, don't know their own size.
They also decay to pointers. This means that every time you use an array's name, it becomes a pointer to the array's first element.
The two things above combined make it necessary that you pass the array's size together with the array, otherwise the function won't know where the array stops in memory.
An exception is
char arrays (more specifically C strings). The trick with those is that they're NUL-terminated. The last element is NUL aka
'\0', so a function knows that it can keep reading elements until it reaches that NUL.
That's why you can do
std::cout << "Hello!";
without passing the size of
"Hello".
On the other hand,
std::ostream::write() is used for unformatted output, so the
char array you're feeding it need not be a C string, but instead non-text binary data. Which is why you need to pass the size, because it doesn't stop at some 0 value.