首页 > 解决方案 > 将字符串文字分配给 char[] 是如何工作的?

问题描述

标签: c

解决方案


Typically, a string literal is stored in read-only memory; but, when you initialize a string literal to a character array, as in your first example, it gets copied into the character array, which is not in read-only memory. It is the character array that can be modified; not the literal itself.


推荐阅读