Hi @전우경 (WooKyung Jeon) ,
what about int * array and int array [] difference in C or C++?
The pointer occupies the memory space to store the address; the array name is the starting position of an array. The point of the pointer can be modified, but the starting position of the array in memory cannot be modified.
Using sizeof on a pointer gives 4 bytes (32-bit) and 8 bytes (64-bit), while using sizeof on an array name gives the size of the array.
When used as a formal parameter, int a[] and int *a have no practical difference. Of course, if you use a[] as a formal parameter, it can be more obvious that this is an array.
Answers to your other questions:
Using const to define an array is a kind of protection for the data in the array. When trying to modify the contents of an array of const type, an error will be generated at compile time.
Regarding pointers and const, I suggest you read this issue.
Best regards,
Elya
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.