Question

E

enam

Hi,

I am Enam. I have a question

What is the difference between Structure & Array?

Any answer will be appreciated.


rgd
Enam
Dept: MCE
091409
 
K

Kenny McCormack

Hi,

I am Enam. I have a question

What is the difference between Structure & Array?

Any answer will be appreciated.

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...
 
S

Seebs

What is the difference between Structure & Array?

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
 
M

Michael Angelo Ravera

Hi,

I am Enam. I have a question

What is the difference between Structure & Array?

Any answer will be appreciated.

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!"
 
S

spinoza1111

Hi,

I am Enam. I have a question

What is the difference between Structure & Array?

Any answer will be appreciated.

rgd
Enam
Dept: MCE
091409

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/w...languages.html?scp=1&sq=markoff simula&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.
 
S

spinoza1111

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.


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

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.
 
I

Ian Collins

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.

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.
 
P

Peter Nilsson

spinoza1111 said:
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).

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.

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.
 
S

spinoza1111

spinoza1111wrote:



Not in C, it isn't. (Hint: 0-element arrays aren't allowed in C.)

Thanks. We know.
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.
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 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.

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.
 
N

Nick Keighley

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]
 
S

spinoza1111

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.

Didn't know that. Thx.
...is in the same boat as they share grammar.



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.
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.
 
S

spinoza1111

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]

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.
[BTW: yes, I know what an n-tuple is]
 
S

spinoza1111

spinoza1111wrote:

<snip>




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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

C programming 12
C programming 3
Turbo C 0
Turbo C 3
Structure and Union 1
Turbo C 5
c programming 3
Difference between Array & Structure 5

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top