How does c++ calculate the size of unsized array?

You might try this:

(Broken Link Removed)

It looks for '/0', which is the starting position of unused array.

In C++, when you declare an array without specifying its size, it is known as an "unsized array", or sometimes referred to as an "incomplete" or "unbounded" array. The size of an unsized array is not directly calculated by the C++ language itself, as it does not allow this type of declaration.

To calculate the size of an array, the C++ language requires you to specify its size explicitly at declaration or dynamically allocate memory for it at runtime. If you attempt to declare an unsized array in C++, it will result in a compilation error because the compiler needs to know the size of the array in order to allocate memory for it.

Here is an example of declaring an array with a specified size:

```cpp
int array[5]; // Declaring an array with a size of 5
```

In this case, the array `array` has a size of 5, which means it can store 5 elements of type `int`.

If you need to calculate the size of a dynamically allocated array at runtime, you can use the `sizeof` operator. However, this only works for arrays with a known size at compile time, not for unsized arrays. Here is an example:

```cpp
int* dynamicArray = new int[10]; // Dynamically allocating an array with a size of 10

int size = sizeof(dynamicArray) / sizeof(dynamicArray[0]);

delete[] dynamicArray; // Don't forget to deallocate the memory when you're done!
```

In this example, `sizeof(dynamicArray)` returns the total size (in bytes) of the dynamically allocated array. By dividing it by `sizeof(dynamicArray[0])`, which represents the size of each individual element in the array, we can determine the number of elements in the array. However, please note that this method is not applicable for unsized arrays, as they cannot be dynamically allocated in C++.