linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ratheesh k <ratheesh.ksz@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: union to get parts of integer
Date: Mon, 20 Dec 2010 16:10:17 +0530	[thread overview]
Message-ID: <AANLkTikAB_-kO_cmD5VQRtztx=4V9NDcmU4uWBDE=ON8@mail.gmail.com> (raw)

typedef struct {
char parts[4];
} node ;

int i=0x12345678

((node *)&i)->parts[0];
((node *)&i)->parts[1];
((node *)&i)->parts[2];
((node *)&i)->parts[3];

Is there any mechanism to split into bytes using the power of union ?

-Ratheesh

             reply	other threads:[~2010-12-20 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 10:40 ratheesh k [this message]
2010-12-20 12:03 ` union to get parts of integer Reza Hoorfar
2010-12-20 14:44 ` Michal Nazarewicz
2010-12-20 15:30   ` Tim Walberg
2010-12-20 15:40     ` Michal Nazarewicz
2010-12-21 16:22     ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTikAB_-kO_cmD5VQRtztx=4V9NDcmU4uWBDE=ON8@mail.gmail.com' \
    --to=ratheesh.ksz@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).