当前位置: 动力学知识库 > 问答 > 编程问答 >

c - Same program GCC crashes but msvc works

问题描述:

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";
分享给朋友:
您可能感兴趣的文章:
随机阅读: