Hello, I am a student studying C language. I was curious about the name of the language array.
int arr[3] = {99, 77, 55}; Assume that you declared an array of
We know that the variable arr has the address of arr[0].
1) By the way, where is the variable arr stored? Is it in front of the arr[0] variable in memory?
2) Isn't arr a variable? As a result of printing &(arr) It's the same as the address of the arr[0]...
In conclusion, whether the variable arr is in memory, If so, I'd like to know where it is located.
array c pointer
A variable is a representation of a specific memory area (address) in human-readable characters
1) Variables do not have separate storage areas.
For example, if you declare in a function as follows,
void func (void)
{
int arr[3] = {99, 77, 55};
}
Arrange the numbers 99, 77, 55 in the memory area with the stack pointer The memory is calculated from the stack pointer and read and write
2) Arr is the correct variable. 1)In the example in , if the memory address of 99 is 0x1000 The address values for &(arr) and arr[0] are 0x1000
In other words, the value of the variable arr does not exist and is accessed through the relative position of the stack at the time of compilation.
I think the pointer variable is close to the answer you want.
void func (void)
{
int arr[3] = {99, 77, 55};
int* arr_ptr = arr;
}
In the above configuration, if the 99 memory address is 0x1000, 99, 77, 55, 0x1000 values are in order on the memory arr_ptr will have the address value of arr
© 2024 OneMinuteCode. All rights reserved.