The C standard does not permit to assign an array to another array:
char arr[] = "char_arr_one";
char arr2[] = {arr}; // This does not work.
Why it works on a specific implementation as you´d stated, I don´t know, but generally it should not be possible to compile that code without at least one warning.
So maybe you disabled or even ignored warnings?
One link to that context, here:
Why should I always enable compiler warnings?
Nonetheless, this doesn´t bring you the desired result of copying the string "char_arr_one" into arr2.
If you want to store the string, stored inside of arr, in arr2 you can use strcpy in the header string.h:
char arr[] = "char_arr_one";
char arr2[13]; // You need to provide the amount of elements, at least
// as much as are required to store the string inside arr
// the null character.
strcpy(arr2,arr); // Copies the string in arr into arr2.
Note, that you need to specify the elements of arr2, which need to be at least as much as are required to store the string of "char_arr_one" plus the terminating null character \0, when defining arr2. In this case, arr2 needs to have at least 13 char objects.
You could also "automatically" detect the size of arr by using the sizeof operator:
char arr[] = "char_arr_one";
char arr2[sizeof(arr)]; // Automatically detects the size of `arr` and provides
// it for specify the required amount of elements for storing
// the string in arr + the null character.
strcpy(arr2,arr); // Copies the string in arr into arr2.
Beside that, the third argument of arr2[i+1] inside the printf call will get you into Undefined Behavior. At the last iteration, it would print something what lies beyond the array of arr2. So change that to arr2[i].
The corrected code shall be:
#include <stdio.h>
#include <string.h>
int main(){
char arr[] = "char_arr_one";
char arr2[sizeof(arr)];
strcpy(arr2,arr);
printf("%s\n%s\n",arr,arr2);
for(int i = 0; i < 13; i++){
printf("%c %c\n", arr[i], arr2[i]);
}
return 0;
}
Output:
char_arr_one
char_arr_one
c c
h h
a a
r r
_ _
a a
r r
r r
_ _
o o
n n
e e
warning: initialization of ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion](even with no warning options explicitly enabled). You should heed compiler warnings — the compiler knows more about C than you do.