cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/15/13:24:58

From: Charles Terry <cterry AT plinet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Individual Bits
Date: Wed, 15 Apr 1998 07:32:37 -0700
Organization: All USENET -- http://www.Supernews.com
Lines: 35
Message-ID: <3534C505.507B@plinet.com>
References: <35343EFB DOT FA2644E7 AT gold DOT com DOT br>
NNTP-Posting-Host: 10025 AT 207 DOT 174 DOT 3 DOT 109
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Sérgio Vale e Pace wrote:
> 
> Hi Eevryone,
> 
>     I'm trying to make a struct to work something like this:
> 
> defined_struct data;
> data=8;
> data.bit0=1; // data=9
> data.bit2=1; //data=13
> 
> or at least
> 
> defined_struct data;
> data.value=8;
> data.bit0=1; // data=9
> data.bit2=1; //data=13
> 
> but I'm not figuring how can somebody give-me some help.

union{
	int data;
	struct{
	int bit1:1;
	int bit2:1;
	int bit3:1;
	int bit4:1;
	int bit5:1;
	};piece;
};struct_data;
struct_data.data=8;
struct_data.piece.bit1=1;//struct_data.data==9

Charles

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019