286 char* and char[] are different types, but it's not immediately apparent in all cases. This is because arrays decay into pointers, meaning that if an expression of type char[] is provided where one of type char* is expected, the compiler automatically converts the array into a pointer to its first element.
The char type can only represent a single character. When you have a sequence of characters, they are piled next to each other in memory, and the location of the first character in that sequence is returned (assigned to test). Test is nothing more than a pointer to the memory location of the first character in "testing", saying that the type it points to is a char.
char *str = "Test"; is a pointer to the literal (const) string "Test". The main difference between them is that the first is an array and the other one is a pointer. The array owns its contents, which happen to be a copy of "Test", while the pointer simply refers to the contents of the string (which in this case is immutable).
} int main() { char *s = malloc(5); // s points to an array of 5 chars modify(&s); // s now points to a new array of 10 chars free(s); } You can also use char ** to store an array of strings. However, if you dynamically allocate everything, remember to keep track of how long the array of strings is so you can loop through each element and free it.
For cout << &q - operator << (ostream&, char* p) expects that p points to NULL terminated string - and &q points to memory containing "H" but what is after this character no one knows - so you will get some garbage on screen. Use cout << q to print single character.
The difference between char* the pointer and char[] the array is how you interact with them after you create them. If you are just printing the two examples, it will perform exactly the same. They both generate data in memory, {h, e, l, l, o, /0}. The fundamental difference is that in one char* you are assigning it to a pointer, which is a variable. In char[] you are assigning it to an array ...
char* const x is refer to character pointer which is constant, but the location it is pointing can be change. const char* const x is combination to 1 and 2, means it is a constant character pointer which is pointing to constant value.
char *array = "One good thing about music"; declares a pointer array and make it point to a (read-only) array of 27 characters, including the terminating null-character.
It sounds like you're confused between pointers and arrays. Pointers and arrays (in this case char * and char []) are not the same thing. An array char a[SIZE] says that the value at the location of a is an array of length SIZE A pointer char *a; says that the value at the location of a is a pointer to a char. This can be combined with pointer arithmetic to behave like an array (eg, a[10] is ...