字符串文本的存储Storage of String Literals

文本字符串的字符将按顺序存储在连续内存位置。The characters of a literal string are stored in order at contiguous memory locations. 字符串文本中的转义序列(例如,\\ 或 \")将作为单个字符进行计数。An escape sequence (such as \\ or \") within a string literal counts as a single character. null 字符(由 \0 转义序列表示)自动追加到每个字符串并标记该字符串的末尾。A null character (represented by the \0 escape sequence) is automatically appended to, and marks the end of, each string literal. (这会在转换阶段 7 出现。)请注意,编译器无法在两个不同的地址存储两个相同的字符串。(This occurs during translation phase 7.) Note that the compiler may not store two identical strings at two different addresses. /GF 强制编译器将相同字符串的单个副本置于可执行文件中。/GF forces the compiler to place a single copy of identical strings into the executable file.

备注Remarks

Microsoft 专用Microsoft Specific

字符串具有静态存储持续时间。Strings have static storage duration. 有关存储持续时间的信息,请参阅存储类See Storage Classes for information about storage duration.

结束 Microsoft 专用END Microsoft Specific

另请参阅See Also

C 字符串文本C String Literals