c 语言 00字符串 截断,C字符串太大,尾随字符被截断

标准没有指定字符串文字的最大限制,但建议最小尺寸.附件B – 实施数量

The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.

Characters in a string literal (after concatenation) [65 536].

但是,标准中的相同部分也说明如下

Because computers are finite, C++ implementations are inevitably limited in the size of the programs they can successfully process. Every implementation shall document those limitations where known. This documentation may cite fixed limits where they exist, say how to compute variable limits as a function of available resources, or say that fixed limits do not exist or are unknown.

可以安全地假设5MB字符串文字将超过编译器强加的最大限制.您应该参考工具链的文档来确定对字符串文字施加的限制.

如果您使用的是Visual C编译器,则字符串文字的最大大小为16,384字节.从MSDN documentation

The maximum length of a string literal is 16,384 (16K) bytes. This limit applies to strings of type char[] and wchar_t[]. If a string literal consists of parts enclosed in double quotation marks, the preprocessor concatenates the parts into a single string, and for each line concatenated, it adds an extra byte to the total number of bytes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值