This will create a null terminated string hello world\0 in the const segment.
In the main function this string will be copied to the character array.
Let me highlight a few lines from the assembly output to clairfy this.
PUBLIC ??_C@_0M@LACCCNMM@hello?5world?$AA@
This creates a public token.
CONST SEGMENT
??_C@_0M@LACCCNMM@hello?5world?$AA@ DB 'hello world', 00H
CONST ENDS
This assigns the constant null terminated string to the token.
lea rax, QWORD PTR arr_of_chars$[rbp]
lea rcx, OFFSET FLAT:??_C@_0M@LACCCNMM@hello?5world?$AA@
mov rdi, rax ; Set destination to stack location
mov rsi, rcx ; Set source to public token
mov ecx, 12 ; Set counter to number of times to repeat
rep movsb ; Copy single byte from source to destination and increment locations
This sets up the source and destination and copies character by character 12 times which is the length of "hello world" and the null terminator. The destination is a location on the stack and the source is the public token.
hello worldis null-terminated string placed somewhere in the system. When variable is initialized, string is copied to RAM.const char a[] = "hello world"; char b[] = "hello world";. You have 2 exact values, and even if they are global or static, you will have only one memory storage ofhello worldin .rodata section, specially on embedded systems. It will be copied to non-const variable on runtime first.bwill normally be placed in the data section with the corresponding initialization value. The initialization will occur as a consequence of the program being loaded into memory.