Difference between Array & Structure

Discussion in 'C Programming' started by Seebs, Mar 30, 2010.

1. SeebsGuest

On 2010-03-30, enam <> wrote:
> my name is enam. i hv a qs:
> Difference between Array & Structure

One alphebetizes under A, the other under S.

Seriously, this question is too broad to have any meaning. How about you
if there's something you don't understand?

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach /
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

Seebs, Mar 30, 2010

2. enamGuest

hi

my name is enam. i hv a qs:
Difference between Array & Structure

rgd
enam
091409

enam, Mar 30, 2010

3. Keith ThompsonGuest

Seebs <> writes:
> On 2010-03-30, enam <> wrote:
>> my name is enam. i hv a qs:
>> Difference between Array & Structure

>
> One alphebetizes under A, the other under S.
>
> Seriously, this question is too broad to have any meaning. How about you
> if there's something you don't understand?

And please, spell out your words. "I have a question" is much easier
to read than "i hv a qs".

--
Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Keith Thompson, Mar 30, 2010
4. Michael Angelo RaveraGuest

On Mar 29, 11:32 pm, enam <> wrote:
> hi
>
> my name is enam. i hv a qs:
> Difference between Array & Structure
>
> any reply will be appreciated
>

C's concept of a "struct"ure is, what in Computing Science parlance is
referred to as an "ordered, heterogenous array". C's concept of an
array is what is what in Computing Science palance is referred to as a
"homogeneous array".

Yes, you could support unordered heterogenous arrays in C by casting
pointers in an array, etc.

The main advantage of a C struct is that you can define the pieces to
whatever level of detail you happen to care to (subject to some
usually reasonable limitations). The main disadvantage is that you
MUST do so.

C arrays also permit nesting, but you are stuck with the limitation
that all of the elements will be of the same time. You can, however,
have arrays of structs of arrays of structs also.

Michael Angelo Ravera, Mar 30, 2010
5. Dr Malcolm McLeanGuest

On 30 Mar, 07:32, enam <> wrote:
>
> my name is enam. i hv a qs:
> Difference between Array & Structure
>

/* arrays */
int x[20];
double x[20];
double x[20][20];

/* structures */
struct point
{
double x;
double y;
double z;
};

struct employee
{
char firstnames[32];
char surname[32];
int payrollno;
double salary;
};

/* array of structures */

struct point triangle[3];

That's basically what you need to know.

Dr Malcolm McLean, Mar 30, 2010
6. ng2010Guest

enam wrote:
> hi
>
> my name is enam. i hv a qs:
> Difference between Array & Structure
>
> any reply will be appreciated
>

Arrays are homogeneous and structs are heterogeneous.

ng2010, Apr 3, 2010