473,839 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How come C allow structure members to be addressed like an array ?

#include <stdio.h>

typedef struct
{
double x, y, z;
}vector;

int main(void)
{
int i;
vector v;
double *cord;

v.x = 10;
v.y = 1;
v.z = 2;

cord = &v.x;

for(i = 0; i < 3; i++)
{
printf("%f\n", cord[i]);
}
return 0;
}

here's the output i get:
10.000000
1.000000
2.000000

which is the same as v

i don't how it happens as i was just trying some random ideas but
great stuff really. helped me to reduce some of my code to almost
1/3rd its size.
Jun 27 '08
85 2454
Tomás Ó hÉilidhe said:

<racist rant snipped>
>Fortunately for the world, not everyone is as bigoted as you.

Tarring an entire people with a single brush is /never/ appropriate.


People have prejudices for a reason. If I had no prejudice, I'd be
robbed daily. From now on, I won't allow a Roman gypsie within a foot
of me.
If I paid attention to the opinions of bigots, I'd be at risk of becoming a
bigot myself. But I'm not going to assume that all Irishmen are bigots, just
because you are.
I suggest we drop this conversation, given the forum.
I suggest you drop the racism, for your own sake. Hatred is not good for you.
Plus it's the kind of conversation that turns sour very quickly.
You are *way* too late for that.
If you really want to continue you can send me private e-mail.
I have nothing to say to you in private. It seems clear that there isn't much
point saying anything to you in public, either. So - welcome to my bozo bin.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #51
In article <sl************ *******@nospam. invalid>,
Antoninus Twink <no****@nospam. invalidwrote:
>On 15 Jun 2008 at 18:55, Tomás Ó hÉilidhe wrote:
>I suggest we drop this conversation, given the forum. Plus it's the
kind of conversation that turns sour very quickly.

Yes, it's amazing how conversations quickly turn sour when someone
introduces a racist tirade into them.
Yeah. Funny how that works, isn't it? You'd think people could do
better, regardless of the subject matter, but you just don't see it
working out that way in practice.

Jun 27 '08 #52
Joachim Schmitz wrote:
Richard wrote:
>Ben Bacarisse <be********@bsb .me.ukwrites:
.... snip ...
>>>
I think it is quite reasonable that people should be able to
spell their names correctly, but that argument will be lost on
someone who does not even dare let their name be know.

You appear to have totally missed the point. If you re-read
Twinks reply then all the necessary points are therein.

Hint : Most usenet posting Germans convert the German characters
to "oe", "ae" and "ss" etc as appropriate.

In Postings yes, but not neccessarily in Names
Since (that) Richard and Twink are both plonked trolls, nobody is
going to reread their unread junk in the first place.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #53
Keith Thompson wrote:
Tomás Ó hÉilidhe <to*@lavabit.co mwrites:

[...]
>I don't so much have a hatred for them, I just view them as a
dirty filthy people.
<
[...]

Upthread, you wrote:

I suggest we drop this conversation, given the forum.

This will not end until you end it. Stop talking about the "Roma
gypsies", right now. Don't respond to this. Don't try to defend
your opinions. Just shut the hell up about it.
Too late. He has incited my PLONK list as a bigot.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #54
CBFalconer said:

<snip>
Since (that) Richard and Twink are both plonked trolls, nobody is
going to reread their unread junk in the first place.
You are mistaken. Your killfile decisions are not binding on others. People
have to work these things out for themselves.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #55
Nick Keighley <ni************ ******@hotmail. comwrites:
On 15 Jun, 22:56, Tomás Ó hÉilidhe <t...@lavabit.c omwrote:

<snip>

[a list of peoples Tomas O'Eilidhe isn't bigoted about]
>That's a pretty good "tolerance track record" if you ask me. And it's
not like I'm about to start a campaign for Ethnic cleansing... I'm
just not going to let a Roma gypsie near me ever again.

In my country (UK) you'd have problems with the law for behaving the
way you propose (and a good thing too).
Changing the subject line is very, very bad form for those of us who
killfile based on subject. Please do not do it.
Jun 27 '08 #56
On Jun 16, 10:52*am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
wrote:>
In my country (UK) you'd have problems with the law for behaving the
way you propose (and a good thing too).

Warning a Roma gypsie to stay out of my personal space is no different
than shouting SHOO at a dog when it comes too close.

There isn't a court in Britain or Ireland that would find someone
guilty for punching a Roma gypsie. In fact you'd be hard pushed to
even find a policeman that would pursue the matter.
Jun 27 '08 #57
<TROLLING4TRUTH >

On Jun 16, 2:27 am, Tomás Ó hÉilidhe <t...@lavabit.c omwrote:

<SNIP>
I've always hastened to use the cliché term "There's nothing worse
than X", but in this case they're the only words that come to me:
There's nothing worse than a people without pride. There's plenty of
immigrants in the town where I live. There's Eastern Europeans.
There's black Africans. While I'm not overjoyed with immigrants taking
natives' jobs and accommodation, I don't bear any real animosity or
hatred towards them.
Do not bear any 'real' animosity or hatred? Nice to know that.

Feeling a bit xenophobic Tom? The undertones would indicate that.

Someone really should teach you about connotations and denotations.

It's nice you do not bear malice to these people that people come in
to take jobs locals do not want. Or cannot do. Or do not want to do
because it's a family tradition, ie the family tradition of a lot of
people who live in say, Ballymun or someplace like that (4-5th gen
unemployed), living off my tax euro.

Or they go off to university, to then post on c.l.c. and hence do not
want to build the houses, man the petrol stations, work in fast food
joints etc

Someone's got to do it. Just be glad there is.

Ireland's in the EU now. The EU is multicultural and multiracial.
Tough, but you'll get used to it as others have.
Some of them are really nice people, and they're
just here to make a better life for themselves. In fact, their
ambition in life is something a lot of people could aspire to. The
black Africans in particular tend to be extremely pleasant friendly
people; I can smile and say hello to a complete stranger black
African, and he'll say hello back with a warm smile. If I were to do
that to any other stranger, the person would look at me like I'm a
weirdo.
QFT. This is true.
But then there's one immigrant people here that I truly despise: Roma
gypsies. These people have no pride whatsoever. They really are rats.
<...nasty true bits clipped...they are nasty but they are TRUE>
Now up until that point, I'd never been a fan of Roma gypsies, but at
the same time I'd no real animosity or hatred for them. Now though, I
don't even see them as people. There are friends of mine who work in
shops that have had far more experience with Roma gypsies than I have,
but I've never really understood the venomous hatred my friends have
had for them. But now, I understand.
In my experience what you've described is indeed true, but I always
say
these are the selected lot that have come over here to abuse the
system.

I have to say this, as xenophobic as Tom may seem, what he describes
even
I cannot deny as being ludicrous or far from the truth.

Treating them as people to avoid like hell on the street (Just as you
would
any other rough looking type or tramp), is one thing. You can tell
they
are trouble, and you will want to stay clear.

NOT seeing them as even people however is _totally_ different.

I wonder what Tom would say about our local 'gypsies' the tinkers.

They are just as nasty. I have had experiences (really bad ones) with
both camps.

And just like their romany like, a bloody big drain on my tax euro.

What would you say of these people Tom? They are 'Irish' after all.

But I digress, there's nothing worse than a people without pride.
I'm Irish, and I'm from Ireland. The vast majority of people in my
country have English names, you'll see "Stephen McAteer" instead
of "Stiofán Mac an tSaoir".
That's real funny, I would have thought Stephen McAteer would have
been
clearly an Irish name.

Tell me, were you born with your gailge spelling or did you just
change
your name?
Now if they feel comfortable with that, then that's fine.
That's very generous.

A lot of these people would have the names they were born with

I am.

In all likelihood you probably were as well. I am guessing. I
could be wrong, you may have been so unhappy you changed your
name. Fair enuf.
But personally I don't feel comfortable as an Irish person with
an English name.
I'm Irish, I speak Irish and I've an Irish name.
Suits me much better.
I am Irish, I do not speak Irish. I am patriotic enough that I do
want what's best for Ireland on the whole. Good job on the Lisbon
treaty.

But my xenophobia only extends so far.

I welcome a multicultural Ireland, not grudgingly accept it, as
one may construe from your post.

<TROLLING4TRU TH/>
Jun 27 '08 #58
On Jun 16, 10:04 pm, Tomás Ó hÉilidhe <t...@lavabit.c omwrote:
On Jun 16, 10:52 am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
wrote:>
In my country (UK) you'd have problems with the law for behaving the
way you propose (and a good thing too).

Warning a Roma gypsie to stay out of my personal space is no different
than shouting SHOO at a dog when it comes too close.

There isn't a court in Britain or Ireland that would find someone
guilty for punching a Roma gypsie. In fact you'd be hard pushed to
even find a policeman that would pursue the matter.
Oh my God. You are so now in my killfile.
Jun 27 '08 #59
ra**********@gm ail.com writes:
On Jun 16, 10:04 pm, Tomás Ó hÉilidhe <t...@lavabit.c omwrote:
>On Jun 16, 10:52 am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
wrote:>
In my country (UK) you'd have problems with the law for behaving the
way you propose (and a good thing too).

Warning a Roma gypsie to stay out of my personal space is no different
than shouting SHOO at a dog when it comes too close.

There isn't a court in Britain or Ireland that would find someone
guilty for punching a Roma gypsie. In fact you'd be hard pushed to
even find a policeman that would pursue the matter.

Oh my God. You are so now in my killfile.
I suspect someone that advocates harm to minority groups couldn't care
less one way or another.
Jun 27 '08 #60

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
6884
by: Thomas Matthews | last post by:
Hi, Given a structure of pointers: struct Example_Struct { unsigned char * ptr_buffer; unsigned int * ptr_numbers; }; And a function that will accept the structure:
4
2825
by: Thomas Matthews | last post by:
Hi, I'm writing code for an embedded system. In the system a Timer has 4 memory mapped registers of 32-bit lengths in contiguous locations: Timer 0: 0x1000 Configuration register 0x1004 Control register 0x1008 Input register 0x100C Output register.
6
4210
by: Eric Smith | last post by:
Is a structure containing an incomplete array as its last element (per paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an incomplete type? That appears to be indicated by paragraph 22 of section 6.2.5. If so, that seems to make it difficult to allocate such structures, because sizeof() is not allowed on incomplete types (paragraph 1 of section 6.5.3.4). For instance, I've routinely done things like this: struct foo {...
11
2421
by: Mannequin* | last post by:
Hi all, I'm working on a quick program to bring the Bible into memory from a text file. Anyway, I have three questions to ask. First, is my implementation of malloc () correct in the program to follow? Second, have I correctly passed the structure's pointer to the functions in this program?
15
2800
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
10
2136
by: nambissan.nisha | last post by:
I am facing this problem.... I have to define a structure at runtime as the user specifies... The user will tell the number of fields,the actual fields...(maybe basic or array types or multiple arrays,etc) I do not understand how to define the structure at run time.i.e.what fields it will contain.
6
3028
by: noone | last post by:
What is the syntax to access members of a structure without explicitly naming the structure in every access? struct mytype { int a; char* b; long c; } IT; How can I access the structure members in a way similar to the old pascal
5
35826
Banfa
by: Banfa | last post by:
I thought I would write a little article about this because it is regularly asked as a question in the Forums. Firstly this is a C++ issue, it is strictly against the rules of C to create a class with no members. This makes sense because the only real use for a structure or class with no data members and virtual functions is as the base from which to derive other classes and structures or as a container for non-virtual methods. The reason...
5
3805
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);" I thought that it is very hard to memory map structure array. I need both read and write memory mapped file at both side of C# and C++.
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10597
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7834
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.