Skip to content

Commit

Permalink
[faq] 使字符串字面值指针问题的警告更明确
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims authored Mar 18, 2024
1 parent aa00794 commit 5a9d47b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions faq/basic_concepts/c_string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ C 风格字符串是一串以 :cpp:`'\\0'` 结尾的字符. 按照从 C 继承
char const* string = "hello"; // 获取它首元素的指针, 按约定这就被认为是一个字符串
char* string = "hello"; // 警告: 不能修改字符串字面值的内容
char* string = "hello"; // 警告: 字符串字面值不允许被转换为 char*
string[1] = 'a'; // 未定义行为!
你可以用一个字符串字面值初始化字符数组.
Expand Down Expand Up @@ -77,4 +77,4 @@ C 风格字符串是一串以 :cpp:`'\\0'` 结尾的字符. 按照从 C 继承
========================================================================================================================

- :doc:`/faq/c_string_output/main`
- :doc:`/faq/pointer_output/main`
- :doc:`/faq/pointer_output/main`

0 comments on commit 5a9d47b

Please sign in to comment.