C Interview Questions and Answers
Question: Explain which of the following declarations will compile and what will be constant - a pointer or the value pointed at: * const char *
Answer: Note: Ask the candidate whether the first declaration is pointing to a string or a single character. Both explanations are correct, but if he says that it?s a single character pointer, ask why a whole string is initialized as char* in C++. If he says this is a string declaration, ask him to declare a pointer to a single character. Competent candidates should not have problems pointing out why const char* can be both a character and a string declaration, incompetent ones will come up with invalid reasons. |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is C++?
- What is function overloading and operator overloading?
- How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
- What is the difference between declaration and definition?
- What is the difference between realloc() and free()?