Answer the question
In order to leave comments, you need to log in
Why can a string be passed to a char pointer?
What's up, software.
I'm trying to figure it out with memory, and one more issue.
void print(char *b)
{
cout << b << endl;
}
Answer the question
In order to leave comments, you need to log in
"fjkdfjlkdfjlkdfj" is a string literal. In most contexts, it is interpreted as a char array.
An array, when passed to a function, is converted to a pointer to its first element.
A string literal is of type const char[x], where x is the size of the array needed to hold the string.
Such an array can be implicitly converted to const char*.
Some compilers that do not respect the standard allow you to drop const from string literals.
you can pass string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question