473,241 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

real world example of union in c

what can be the real world example of unions used in c
Oct 13 '06 #1
1 6932
9,065 Expert Mod 8TB
The structure used to hold socket addresses (used on at least Windows and Linux)

Expand|Select|Wrap|Line Numbers
  1. struct   in_addr {
  2.     union   {
  3.         struct{
  4.             unsigned  char   s_b1,
  5.                              s_b2,
  6.                              s_b3,
  7.                              s_b4;
  8.         }  S_un_b;
  9.         struct  {
  10.             unsigned  short  s_w1,
  11.                              s_w2;
  12.         }  S_un_w;
  13.         unsigned long  S_addr;
  14.     } S_un;
  15. };
  17. struct sockaddr_in{
  18.     short            sin_family;
  19.     unsigned short   sin_port;
  20.     struct   in_addr sin_addr;
  21.     char             sin_zero[8];
  22. };
Oct 13 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Mike MacSween | last post by:
I frequently hear that there isn't a commercially available dbms that fully implements the relational model. Why not? And which product comes closest. Mike MacSween
by: Raymond Hettinger | last post by:
Proposal -------- I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: >>> map(None,...
by: Fred Exley | last post by:
I have a traditional application using a database and procedural code that works fine. I'm re-writing it using the OOP methodology, just to see how this may be the better way to do things. I...
by: Steven Nagy | last post by:
Howdy, I want to write an application, with some functionality that will detect my "Real World" ip address, ie that of my router, as opposed to the actual IP it is running on which is a...
by: dost | last post by:
plzz give me the answer of these question 1 Give exmples of virtual func and pure virtual func in real world 2 Give example of function overloading in real world 3 Write the structure of...
by: Richard Heathfield | last post by:
I found something interesting on the Web today, purely by chance. It would be funny if it weren't so sad. Or sad if it weren't so funny. I'm not sure which. ...
by: d.adamkiewicz | last post by:
Hello Folks Anybody can show me real world singleton class example? Something that works (is implemented) as part of working solution. Does it make sense to create database handler class that...
by: bluejack | last post by:
A recent post asking for help with unions reminded me of this component of the C language that I have only used a couple of times, and those almost entirely out of personal whim -- Unions for the...
by: Tyno Gendo | last post by:
Hi everyone I need to move on a step in my PHP... I know what classes are, both in PHP4 and 5 and I'm aware of "patterns" existing, but what I'm looking for are some real world projects eg....
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.