gpt4 book ai didi

c - 在 C 中,bool( boolean 值)占用多少空间?是 1 位、1 字节还是其他?

转载 作者:太空狗 更新时间:2023-10-29 16:29:42 25 4
gpt4 key购买 nike

在 C 中,bool( boolean 值)占用多少空间?是 1 位、1 字节还是其他?程序是 32 位还是 64 位重要吗?

最佳答案

如果您指的是 C99 _Bool,请尝试:

printf("%zu\n", sizeof(_Bool)); /* Typically 1. */

注意标准说:

6.2.5

An object declared as type _Bool is large enough to store the values 0 and 1.

大小不能小于一个字节。但是大于一个字节是合法的。

关于c - 在 C 中,bool( boolean 值)占用多少空间?是 1 位、1 字节还是其他?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8014161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com