I am Enam. I have a question
What is the difference between Structure & Array?
Any answer will be appreciated.
rgd
Enam
Dept: MCE
091409
My guess is that, just as the last time you posted this, you *won't*
appreciate the answers (including this one) that you get here.
--
(This discussion group is about C, ...)
Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...
Well, the obvious difference is that, if you were going to a school
worth the money, one of them would have been explained by your professor
in the first week of class, and the other in the second.
> Any answer will be appreciated.
Answer is, stop spamming the newsgroup with homework questions. Read your
textbook or attend classes. If your professor is encouraging you to do
this, you should be aware that your professor is telling you to do something
rude and ineffectual.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
How about searching the newsgroup archives for the answer that I
posted the last time that this question was asked?
People here are willing to help, but you have to do a little (if you
will excuse the expression) homework before they are willing to
respond.
This question, as stated and strictly speaking, is off topic and
should be submitted to a more general computing science group unless
you are specifically interested in answers about C.
But, even if you were to find the right group, the question wouldn't
be welcome there either because it would be found in either the
founding document of the newsgroup or in the FAQ.
So, an experession that you will have to get used to, if you are going
to be in the field "RTFM!"
An array is an ordered n-tuple of zero, one or more elements, each of
which has the same type.
A structure is an ordered n-tuple of one or more elements which may
have different types; although my compiler does not allow me to
declare a structure with no members, the Standard doesn't appear to me
to define a structure with zero members (comments on this from people
more familiar with the Standard are welcome).
A union is one value which may have one of an ordered n-tuple of types
(same cautions apply to the question of whether a union may be
declared with no types).
[A union is also a group of employees formed for the purpose of
collective bargaining with management; according to John Markoff of
the New York Times as
http://www.nytimes.com/2002/08/14/world/kristen-nygaard-75-who-built-framework-for-modern-computer-languages.html?scp=1&sq=markoff%20simula&st=cse,
Danish labor unions were key in the development of the first OO
language (Simula); in addition, union membership tends to reduce
interpersonal sniping and bullying amongst people who are a dime a
dozen professionally.]
A list, which cannot be implemented with a C construct directly, is an
UNORDERED n-tuple of zero, one or more elements. It is commonly
implemented in C as a linked list; incompetent programmers put the
list entry into the list; competent programmers put an address of the
list entry into the list.
If you'd taken computer science, Dweebach, it would be easier to
answer the question than insulting the guy. Maybe he's trying to get a
straight answer. Maybe he's conducting a test to see just how stupid
and bone-headed the collective mind of clc is.
<snip>
> An array is an ordered n-tuple of zero, one or more elements, each of
> which has the same type.
Not in C, it isn't. (Hint: 0-element arrays aren't allowed in C.)
> A structure is an ordered n-tuple of one or more elements which may
> have different types; although my compiler does not allow me to
> declare a structure with no members, the Standard doesn't appear to me
> to define a structure with zero members (comments on this from people
> more familiar with the Standard are welcome).
Structures, like arrays, must have at least one member.
> A union is one value which may have one of an ordered n-tuple of types
> (same cautions apply to the question of whether a union may be
> declared with no types).
It can't.
<nonsense snipped>
> A list, which cannot be implemented with a C construct directly,
int list[64];
> is an
> UNORDERED n-tuple of zero, one or more elements. It is commonly
> implemented in C as a linked list; incompetent programmers put the
> list entry into the list; competent programmers put an address of the
> list entry into the list.
That's about as meaningful as the claim that incompetent walkers wear
shoes whereas competent walkers wear boots. In practice, both techniques
are useful, and the one you choose depends on the circumstances.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
Maybe he's just curious about how many people will reply with an
incorrect answer. So far, there's just been one: you.
The OP would do well to consult his textbook, or pay more attention in
class, or both. The clc newsgroup is no substitute for either.
It would be amusing to see a programmer attempt to put the address of a
character into a list of characters. Or a walker attempt to put boots
into a shoe box.
--
Ian Collins
It is a constraint violation. The C grammar requires at
least one member. A comforming implementation can offer
empty structs as an extension, provided it issues at least
one diagnostic.
> A union ...
...is in the same boat as they share grammar.
<snip>
> A list, which cannot be implemented with a C construct
> directly, is an UNORDERED n-tuple of zero, one or more
> elements. It is commonly implemented in C as a linked
> list;
Unordered lists are commonly implemented with arrays as
well. Where linked lists come in most handy is when the
number of elements is unbounded (limits of memory
notwithstanding.)
> incompetent programmers put the list entry into the list;
> competent programmers put an address of the list entry
> into the list.
Do you think there's a need to use pointers for variables
in general? All the latter does is substitute an intermediate
object for the entity. This may be justified in certain
circumstances, but in C it may sometimes add a level of
needless complication.
--
Peter
Thanks. We know.
>
> > A structure is an ordered n-tuple of one or more elements which may
> > have different types; although my compiler does not allow me to
> > declare a structure with no members, the Standard doesn't appear to me
> > to define a structure with zero members (comments on this from people
> > more familiar with the Standard are welcome).
>
> Structures, like arrays, must have at least one member.
I'll alert the media. This is a bug in C, since I can easily see the
need (in for example a code generator) for a structure with no
elements. But persuading you of its value would be like a Greek slave
trying to persuade Marcus Tullius Rhodomontadus that zero is a number.
>
> > A union is one value which may have one of an ordered n-tuple of types
> > (same cautions apply to the question of whether a union may be
> > declared with no types).
>
> It can't.
Again, I'll alert the media. But the fact that you don't want to
speculate about the value of such cases means you're not a programmer
that I need respect.
>
> <nonsense snipped>
>
> > A list, which cannot be implemented with a C construct directly,
>
> int list[64];
(I was wrong below: a SET is unordered and a list is not.)
This is the worst way of implementing a list, since it's impossible
order less than NP to insert things. You can delete by leaving holes
and later reorganize order some meaningful fraction of NP.
>
> > is an
> > UNORDERED n-tuple of zero, one or more elements. It is commonly
> > implemented in C as a linked list; incompetent programmers put the
> > list entry into the list; competent programmers put an address of the
> > list entry into the list.
>
> That's about as meaningful as the claim that incompetent walkers wear
> shoes whereas competent walkers wear boots. In practice, both techniques
> are useful, and the one you choose depends on the circumstances.
Yeah, I was wrong; I misstated an important distinction; in CJ Date's
text on data base he calls a list that which has an order a set that
which does not. Alert the media. A SET is unordered: a LIST is not.
The distinction matters, however, not the words. And as you know, I
was thinking of the incompetent example you published in C Unleashed,
in which the node values are plugged no matter how large into your
list, foolishly.
Then why post disinformation in the first place?
<snip>
>> Structures, like arrays, must have at least one member.
>
> I'll alert the media. This is a bug in C,
Raise a DR with ISO and see how far you get.
<snip>
>>> A union is one value which may have one of an ordered n-tuple of types
>>> (same cautions apply to the question of whether a union may be
>>> declared with no types).
>> It can't.
>
> Again, I'll alert the media. But the fact that you don't want to
> speculate about the value of such cases means you're not a programmer
> that I need respect.
A union with no members is a syntax error. There's nothing to speculate
*about*.
>> <nonsense snipped>
>>
>>> A list, which cannot be implemented with a C construct directly,
>> int list[64];
>
> (I was wrong below:
You were wrong above, too.
> a SET is unordered and a list is not.)
Whether a list is ordered depends on whether you need it to be ordered.
The distinguishing characteristic of a set is not its ordering (or lack
thereof) but the uniqueness of its members.
> This is the worst way of implementing a list,
Well, I can think of even worse ways - but that's not the point of the
example, which was to demonstrate the falsity of your claim. This it
achieved admirably.
<nonsense snipped>
> > I am Enam. I have a question
>
> > What is the difference between Structure & Array?
twit (see responses to similar recent questions as to why I think
this)
> An array is an ordered n-tuple of zero, one or more elements, each of
> which has the same type.
<snip>
this is simply staggering. You critcise other people for not giving
sensible answers then you post this Computer Science From Hell. How
likely is it that someone who doesn't know what an array is will know
what an n-tuple is? [yeah I know someone who started with very
theoretical comp sci background- how likely is it that the OP is such
a person]
[BTW: yes, I know what an n-tuple is]
Didn't know that. Thx.
>
> > A union ...
>
> ...is in the same boat as they share grammar.
>
> <snip>
>
> > A list, which cannot be implemented with a C construct
> > directly, is an UNORDERED n-tuple of zero, one or more
> > elements. It is commonly implemented in C as a linked
> > list;
>
> Unordered lists are commonly implemented with arrays as
> well. Where linked lists come in most handy is when the
> number of elements is unbounded (limits of memory
> notwithstanding.)
I'd say "limits of memory aside" instead, but I get your meaning.
>
> > incompetent programmers put the list entry into the list;
> > competent programmers put an address of the list entry
> > into the list.
>
> Do you think there's a need to use pointers for variables
> in general? All the latter does is substitute an intermediate
> object for the entity. This may be justified in certain
> circumstances, but in C it may sometimes add a level of
> needless complication.
If a linked list is meant to be reusable then you have no control over
how big the node data shall be and will be exposed to slow performance
if nodes are large.
And in either case, developing a truly general linked list in C is
"hard" (as in "hard and stupid" not "hard and elegant") because there
is no "data type" apart from void that means "unknown data type".
There was in old Basic and VB: it was the Variant data type. But void
doesn't mean that.
The problem is solvable elegantly only in object oriented languages
with generic types.
>
> --
> Peter
Well, I knew what an n-tuple was before I had access to a computer. I
think I first encountered it when I found Alan Turing's 1936 paper on
the Turing Machine in 1968 in the back room of Truman Metzel's "Great
Expectations" bookstore which used to be near the campus of
Northwestern University in Evanston, Illinois.
A double is two things, a triple is three, a quadruple four...baby
stuff.
Today, I'd say there's no excuse not to know what "n-tuple" means,
since all you need to do is type it into the Google search bar. It is
indeed a most amusing paradox that precisely at the point where the
technical apparatus contains so much knowledge, the former knowers
become such gibbering and capering apes, who'd control and "simplify"
language.
My only mistake in the original response was significant and you
should have found it. I said a list can be unordered but in data base
theory a list is ordered and a set is not.
>
> My only mistake in the original response was significant
To which of your several significant mistakes are you referring?
Richard, how much does SAMS publishing pay you to disrupt this forum?
I know they abuse authors and produce crap books. I also have a friend
who was sued by them on a trumped up charge of telephone harassment
for making a web site describing how they treat freelancers. I
wouldn't be surprised if you aren't here to disrupt sales of Schildt's
book which is from a real publisher.
<snip>
> Richard, how much does SAMS publishing pay you to disrupt this forum?
Edward, when did you stop beating your wife?
<nonsense snipped>
> Richard, how much does SAMS publishing pay you to disrupt this forum?
Wait, I thought that was MI5?
--
Ben Pfaff
http://benpfaff.org