问题描述:

This question already has an answer here:

  • Modify a string with pointer [duplicate]

    4 answers

网友答案:

In C all string literals are read only arrays of characters. Trying to modify a string literal leads to undefined behavior. That's the reason you should only use const char * when having pointers to string literals.

Try to use your own array instead:

char c[] = "HELLO";
相关阅读:
Top