布尔值 [英] Boolean Values
问题描述
如何在c中定义布尔值? (一个值只能是
1或0)当我声明变量的内存时,我觉得内存丢失很糟糕
不需要那么多内存。 />
-
Ian Tuomi
Jyv?skyl ?,芬兰
非常有趣的scotty,现在把我的衣服放下来。
GCS d-s +:a --- C ++> $ L +> +++ $ E- W + N +!o> + w ---
!O-!M-t +!5!X R + tv-b ++ DI +!DG e-> +++ h!
注意:从地址中删除NOSPAM
How can I define a boolean value in c? (an value that can only be either
1 or 0) I feel bad for the memory loss when declaring ints for variables
that do not need that much memory.
--
Ian Tuomi
Jyv?skyl?, Finland
"Very funny scotty, now beam down my clothes."
GCS d- s+: a--- C++>$ L+>+++$ E- W+ N+ !o>+ w---
!O- !M- t+ !5 !X R+ tv- b++ DI+ !D G e->+++ h!
NOTE: Remove NOSPAM from address
推荐答案
L +> +++
L+>+++
E- W + N +!o> + w ---
!O-!M-t +!5!X R + tv-b ++ DI +!DG e-> +++ h!
注意:从地址中删除NOSPAM
E- W+ N+ !o>+ w---
!O- !M- t+ !5 !X R+ tv- b++ DI+ !D G e->+++ h!
NOTE: Remove NOSPAM from address
Ian Tuomi< ia ******* @ co。 jyu.fi>写在
news:bm ********** @ phys-news1.kolumbus.fi:
Ian Tuomi <ia*******@co.jyu.fi> wrote in
news:bm**********@phys-news1.kolumbus.fi:
如何定义布尔值c中的值? (一个只能是1或0的值)当声明不需要那么多内存的变量时,我觉得内存丢失很糟糕。
How can I define a boolean value in c? (an value that can only be either
1 or 0) I feel bad for the memory loss when declaring ints for variables
that do not need that much memory.
你不能做我认为你真正想要的东西,这会给你
只能容纳一个或零的东西:
struct MyBool
{
int boolean:1;
};
struct MyBool标志;
flag.boolean = 1;
这仍然使用完整的int。如果你真的想要一个仅使用一位的布尔值
然后在非标准的
模式下使用带有C编译器的8051,并用''声明你的布尔值比特''类型。
-
- 马克 - >
-
You can''t do what I think you really want in C, this will give you
something that can only hold a one or a zero:
struct MyBool
{
int boolean : 1;
};
struct MyBool flag;
flag.boolean = 1;
This still uses a full int though. If you really want to have a boolean
that uses one bit only then use an 8051 with a C compiler in non-standard
mode and declare your booleans with the ''bit'' type.
--
- Mark ->
--
这篇关于布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!