473,804 Members | 2,028 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 2448
CBFalconer <cb********@yah oo.comwrites:
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.
Even for your useless ramblings I must wonder how people "reread"
something that is "unread".

Another point : I am quite correct above. No two ways about it.
Jun 27 '08 #61
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).

If they come
within a metre, I'll raise my fist out in front of them and tell them
to get away from me.
threatening behaviour, conduct liable to cause a breech of the peace

If they proceed further, they're going home with
less teeth. I think that's the fairest I can be about it.
assault occaising actual bodily harm. Possibly Grevious Bodily
Harm (a more serious offence). Our justice system is loaded against
(gives automatic heavier sentences) to race hate crimes.

I have seen Roma begging in Eastern Europe. They looked to be starving
to me.

Hitler included the Roma in his extermination camps. This is often
forgotten.
--
Nick Keighley
Jun 27 '08 #62
ra**********@gm ail.com wrote:
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.
When did Google Groups start providing killfile facilities? :-)

Jun 27 '08 #63
In article <g3**********@r egistered.motza rella.org>,
Richard <rg****@gmail.c omwrote:
>ra**********@g mail.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.
Um, NOBODY cares who is or isn't in anyone else's killfile.

Whether it has anything to do with any particular subject is so not
relevant...

Jun 27 '08 #64
In article <g3**********@r egistered.motza rella.org>,
Richard <rg****@gmail.c omwrote:
>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.
Grow up and get a threaded newsreader.

(I am a strong believer in changing the Subject lines as appropriate as
threads evolve and change)

Jun 27 '08 #65
ga*****@xmissio n.xmission.com (Kenny McCormack) writes:
In article <g3**********@r egistered.motza rella.org>,
Richard <rg****@gmail.c omwrote:
>>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.

Grow up and get a threaded newsreader.

(I am a strong believer in changing the Subject lines as appropriate as
threads evolve and change)
This thread did not evolve and change. It was already getting nasty so I
binned it.

Jun 27 '08 #66

I realise this entire thread is a farce, but I find it amusing and
entertaining so I'm going to roll with it... :-D
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.

My local video store has a few Polish people working there. Before I
started my own business recently I wanted to do some part-time work
just to keep me going. But alas, the jobs were taken by foreigners.

Ireland's in the EU now. The EU is multicultural and multiracial.
Tough, but you'll get used to it as others have.

It's all about the ratio. At the moment in Ireland, more than 1 in 10
people is Polish. Now I've nothing against the Polish, but I think
we've been more than generous by allowing our own native population to
drop to 90%. We have enough foreigners here.

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

They like to be called "Travellers ". Ten years ago, I despised them,
but in recent years they've come along nicely. They're sending their
kids to school now and they're actually finishing school and going on
to get apprenticeships . Unfortunately though, the travellers in the
countryside are still living their career criminal lives.

If the Roma gypsies stop abusing their kids and actually start sending
them to school, my opinion of them will change.

That's real funny, I would have thought Stephen McAteer would have
been
clearly an Irish name.

Sort of. It's clearly a pure-bred Irish name that was Anglisiced, but
still if it were 100% Irish it would be Stiofán Mac an tSaoir (which
by the way is a surname you can actually take meaning from).

Tell me, were you born with your gailge spelling or did you just
change
your name?

My birthcert has an English name on it. I changed it to Irish a few
years ago. Now I've got everything in Irish, including my passport.

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.

I wasn't so much unhappy, more like I felt misrepresented by an
English name. I'm fluent in Irish, I'm proud to be Irish... yet I had
this English name. Just didn't fit.

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.

I didn't even vote for the simple reason that I didn't know anything
about it. I heard something about more taxes and losing neutrality in
war... but that's all. I heard the treaty's a couple of hundred pages
long so I just gave up on it.

But my xenophobia only extends so far.

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

Again, it's about the ratio. I don't want to see an Ireland that's 80%
Irish. I was in a pub in Cork city recently and there were more Polish
than Irish in the place (and this was a pretty big pub).
Jun 27 '08 #67
Tomás Ó hÉilidhe <to*@lavabit.co mwrites:
I realise this entire thread is a farce, but I find it amusing and
entertaining so I'm going to roll with it... :-D
What you mean is that you landed yourself in the doggy doo and are now
trying to get out of it by being purposely "extreme" to mask the real
extremities of your views. It won't wash.
Jun 27 '08 #68
On Jun 16, 3:35*pm, Richard<rgr...@ gmail.comwrote:
What you mean is that you landed yourself in the doggy doo and are now
trying to get out of it by being purposely "extreme" to mask the real
extremities of your views. It won't wash.

I'm racist against Roma gypsies. Can't be more direct than that about
it.
Jun 27 '08 #69
On 16 Jun 2008 at 18:46, santosh wrote:
Again you fail to understand that there is such a thing called
topicality. Even you must admit that the current subject is simply not
topical in clc. And it's not hair-splitting or pedanticism either. The
subject is *massively* off-topic.
Why not tell that to Richard Heathfield, Keith Thompson, Flash Gordon,
CBFalconer, Nick Keighley, and one... santosh, who have all taken an
active part in this discussion?

Jun 27 '08 #70

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

Similar topics

19
6879
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
4207
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
2419
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
2789
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
2135
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
3026
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
35806
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
3803
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
9593
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
10595
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
10343
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...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
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
7633
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...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.