A char array is harder to manage than a string and certain functions may only accept a string as input, requiring you to convert the array to a string. It's better to use strings, they were made so that you don't have to use arrays.
By happenstance, I stumbled upon the words cha, char and chai in the dictionary today, all defined as meaning tea in informal British English. I lived and worked in London for some time, but never ...
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 *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 ...
Each element of the alphabet array is a char * ( a char pointer aka a string). One possible solution would be to change the alphabet array to a char array (and all the double-quotes changed to single quotes in the declaration).
Im fairly new to coding in C and currently im trying to create a function that returns a c string/char array and assigning to a variable. So far, ive observed that returning a char * is the most ...
The code is essentially correct. The problem is the data that you chose to put in byte_loop [10]. It's pretty much all unprintable or invalid ASCII codes. Try using 0x61 through 0x6a (a through j) instead. You'll probably want to add code to handle non-printable values or non-ASCII values, after consulting an ASCII table to see what's valid for your purposes. If this answers your question ...