What I was always doing is:
int arr[] = {2, 3, 4};
and it always worked.
I’ve heard of a better way to initialize new array, using the pointer:
int *arr = {2, 3, 4};
However, it doesn’t work in any IDE, it throws some errors like int differs in levels of indirection from int, or too many initializers. How should I do this?
That initialization seems to work for me, on gcc, but not correctly.
The former isn’t a correct way to initialize an array.
For a char*, it makes more sense
The difference:
The former is written to the Rodata (constant, read-only data) section of the assembly, while the latter, resides in the read/write Data-Segment. Any attempt to change the former, might result in a segmentation-fault.
The places where the values are stored are different.