0
Something about variables , pointers and Asterisk in declaration
What happen when i write char *str1 = "hello!"; Why does it create an array str1[] automatically? Is *str1 a pointer? If so why does *str1 points to the first element of the array str1 ? Is pointers of the rest of the elements created ? https://code.sololearn.com/cJ8IQevzq99P/?ref=app
1 Answer
+ 3
In C++, arrays and pointers are interchangable. The programmer is responsible for making sure you don't access beyond the allocated memory. There is a single variable str1. It can be used as either a pointer or array.