How does printf display a string from a char*?
c++, char, pointers
Solution
`*letter` is actually a character; it's the first character that `letter` points to. If you're operating on a whole string of characters, then by convention, functions will look at that character, and the next one, etc, until they see a zero ('\0') byte.
In general, if you have a pointer to a bunch of elements (i.e., an array), then the pointer points to the first element, and somehow any code operating on that bunch of elements needs to know how many there are. For `char*`, there's the zero convention; for other kinds of arrays, you often have to pass the length as another parameter.
Problem
Consider a simple example ``` Eg: const char* letter = "hi how r u"; ``` letter is a const character pointer, which points to the string "hi how r u". Now when i want to print the data or to access the data I should use `*letter` correct? But in this situation, shouldn't I only have to use the address in the call to printf? ``` printf("%s",letter); ``` So why is this?