Question: I am working on my own C++ project and want to do below scenario:

1. Writing some values into `long int` array
2. Reading `double` from `long int` array int `double` array

So, I wrote the code as below:

```
long int lArray [100];
double dArray[100];

for (int i = 0; i < 100; i ++)
   lArray[i] = i * i;

double *dPointer = lArray;

for (int i = 0; i < 100; i ++)
   dArray[i] = *(dPointer++ + 1);

```

But, When I compile that, face `[Error] cannot convert long int* to double* in initialization` error.
How can I solve this problem?!

Thanks In Advance :)

Answer: 
If you want to interpret `long`s as `double`s, you should use `reinterpret_cast`:

```
double *dPointer = reinterpret_cast<double*>(lArray);

```

You should also ensure that `sizeof(double) == sizeof(long)`, because for example in VS it doesn't hold (better use `unsigned long long`):

```
static_assert(sizeof(double) == sizeof(long), "sizes are different");

```
First up, you need to explicitly cast the pointers:

```
double *dPointer = reinterpret_cast<double*>(lArray);

```

However, the encoding of `long int` isn't compatible with the encoding of a `double`. They may both be 8 bytes wide (depending on your platform) but that's about it. The only guarantee is that a both represent zero as 8 0-bytes. Anything else isn't compatible, that's why your long is `0CDEFF3333333333` but as a double it `1.10831057258179508893524397544E-246`.

Why not just use an array of `double` in the first place? Also, since you're doing C++ take a look at the `vector` and `array` templates in the standard library.