I am learning C++ and have got a question that I cannot find the answer to.
What is the difference between a char constant (using single quotes) and a s
"a" is an array of characters that just happens to only contain one character, or two if you count the \0 at the end. 'a' is one character. They're not the same thing. For example:
#include
void test(char c) {
printf("Got character %c\n", c);
}
void test(const char* c) {
printf("Got string %s\n", c);
}
int main() {
test('c');
test("c");
}
This will use two different overloads; see http://codepad.org/okl0UcCN for a demo.