Question: I have a question regarding passing c string into function.

If I have a function:

```
void reverse(char* c){
   //here is the reverse code
}

```

In the main:

```
int main(){
   char* c1="abcd";
   char c2[5]="abcd";
   char * c3=new char[5];
   c3="abcd";
}

```

In my test, only c1 is not allow to pass into the function, other two works fine. I would like to know why c1 is a wrong usage? Thank you very much!

Answer: 
Your code is C++, not C; `new char[5]` is a syntax error in C.

C and C++ are two different languages. In C++, string literals are `const`, and passing a string literal to a function that takes a `char*` argument is an error. You should have gotten an error message (which you haven't bothered to show us) from your C++ compiler.

(If you were using a C compiler, it would have accepted a call like `reverse("foo")`, but it would have complained about the `new char[5]`.)
`c1` will point to a string literal and attempting to modify a string literal is undefined behavior, this is based on the assumption that `reverse` will attempt to reverse the string in place.