Tuesday, April 20, 2010

comp.lang.c - 25 new messages in 7 topics - digest

comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en

comp.lang.c@googlegroups.com

Today's topics:

* Large numbers, floating point number questions - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/f2843ba5ccf77a70?hl=en
* Another note about Peter Seebach's network behavior - 9 messages, 6 authors
http://groups.google.com/group/comp.lang.c/t/d9349e3ce65713a1?hl=en
* Tibco Administrator , Orlando, Florida - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/4714bb4d2597f343?hl=en
* seebs/schildt - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/0c84debf9a4f144b?hl=en
* OT: [NILGES] portability [Was: In the Matter of Herb Schildt:...] - 2
messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/caf17fab4e7d8530?hl=en
* Generic programming in C - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/efedbc3e3c37ccc1?hl=en
* Question - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/0643f4ad3c239efe?hl=en

==============================================================================
TOPIC: Large numbers, floating point number questions
http://groups.google.com/group/comp.lang.c/t/f2843ba5ccf77a70?hl=en
==============================================================================

== 1 of 5 ==
Date: Tues, Apr 20 2010 4:05 pm
From: Ben Bacarisse


Chad <cdalten@gmail.com> writes:

> On Apr 20, 3:38 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
>> Chad <cdal...@gmail.com> writes:
<snip>
>> >   float acc = 0;
>> >   float i;
>>
>> >   for (i = 1; i <= n; i++) {
>> >     acc += ((100) *1/i);
>> >   }
>>
>> Using a float as a loop index is not a good idea.
>
> What's the alternative?

An integer type is preferable. I don't think there is anything actually
wrong with the above as far as C is concerned (because of the guarantees
C makes about floating point arithmetic) but you'll make everyone read
the code several times just to be sure.

<snip>
>> What accuracy do you need?  S(100) is exactly
>>
>
> Maybe around S(20).

That's not an accuracy. Do you need to know what S(20) is exactly
(39750532290178371794884752 / 55835135) or will an approximation do? If
so, what accuracy do you need? Would 7.12e17 be good enough or do you
need 7.119268591394715e17 or better?

--
Ben.


== 2 of 5 ==
Date: Tues, Apr 20 2010 5:00 pm
From: Chad


On Apr 20, 3:57 pm, "bartc" <ba...@freeuk.com> wrote:
> Chad wrote:
> > On Apr 20, 3:26 pm, "bartc" <ba...@freeuk.com> wrote:
> >> "Chad" <cdal...@gmail.com> wrote in message
>
> >>news:276a4ab9-f24e-4cda-b3f3-54eb0371e407@g11g2000yqe.googlegroups.com...
>
> >>> The following program is my attempt to calculate the formula at the
> >>> following url...
>
> >>>http://i23.photobucket.com/albums/b363/CompressorX/1.jpg
> >>> unsigned long fact(unsigned long);
> >>> unsigned long sum_fact(unsigned long);
> >>> float harmonic(unsigned long);
>
> >> Why not use float (or, better, double) for fact() and sum_fact()
> >> too? Then you won't get the overflow problems so early.
>
> >> --
> >> Bartc
>
> > Okay, I don't get how using float (or double) for fact() and
> > sum_fact() would prevent overflow problems early on.
>
> If your 'unsigned long' is, say, 32-bits, then the largest factorial it can
> store is 12!
>
> 13! would require about 33 bits I think, and if you try and do it using 32
> bits, it will give funny results.
>
> Summing the factorials has similar problems; integers just have a too narrow
> range.
>
> Floats have a much wider range: typically a float might go up to around
> 1e38, and a double up to about 1e300. But a double only gives some 16
> digits of precision.
>
> Simplify your program to *only* show factorials from 1 to 100 (forget
> command line input, just use a loop), and you will
> see where it goes wrong. Then put in doubles, and see the difference.
>


How many numbers would 1e300 produce? What can I say, my math isn't up
to par.

== 3 of 5 ==
Date: Tues, Apr 20 2010 5:06 pm
From: Chad


On Apr 20, 4:05 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> Chad <cdal...@gmail.com> writes:
> > On Apr 20, 3:38 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> >> Chad <cdal...@gmail.com> writes:
> <snip>
> >> >   float acc = 0;
> >> >   float i;
>
> >> >   for (i = 1; i <= n; i++) {
> >> >     acc += ((100) *1/i);
> >> >   }
>
> >> Using a float as a loop index is not a good idea.
>
> > What's the alternative?
>
> An integer type is preferable.  I don't think there is anything actually
> wrong with the above as far as C is concerned (because of the guarantees
> C makes about floating point arithmetic) but you'll make everyone read
> the code several times just to be sure.
>
> <snip>
>
> >> What accuracy do you need?  S(100) is exactly
>
> > Maybe around S(20).
>
> That's not an accuracy.  Do you need to know what S(20) is exactly
> (39750532290178371794884752 / 55835135) or will an approximation do?  If
> so, what accuracy do you need?  Would 7.12e17 be good enough or do you
> need 7.119268591394715e17 or better?
>
> --


Okay, I misread that. 7.12e17 is good enough.


== 4 of 5 ==
Date: Tues, Apr 20 2010 5:07 pm
From: Keith Thompson


Chad <cdalten@gmail.com> writes:
[...]
> How many numbers would 1e300 produce? What can I say, my math isn't up
> to par.

How many numbers?

1e300 is one number.

It has 301 decimal digits, if that's what you mean: a 1 followed by 300
0s. And you'd need 997 bits to represent it exactly.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <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"


== 5 of 5 ==
Date: Tues, Apr 20 2010 6:13 pm
From: Ben Bacarisse


Chad <cdalten@gmail.com> writes:

> On Apr 20, 4:05 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
<snip>
>>  Do you need to know what S(20) is exactly
>> (39750532290178371794884752 / 55835135) or will an approximation do?  If
>> so, what accuracy do you need?  Would 7.12e17 be good enough or do you
>> need 7.119268591394715e17 or better?
>
> Okay, I misread that. 7.12e17 is good enough.

Then just use double to calculate the factorial and factorial sum and
you should be fine. Even using float for the harmonic sum will give you
more than three significant figures but I'd use double for that as
well. There is no need to be careful about the order in which you sum
the terms.

However, if all you need it S(1) to S(20) it would make sense to
pre-calculate these values and put them in a table.

--
Ben.

==============================================================================
TOPIC: Another note about Peter Seebach's network behavior
http://groups.google.com/group/comp.lang.c/t/d9349e3ce65713a1?hl=en
==============================================================================

== 1 of 9 ==
Date: Tues, Apr 20 2010 4:33 pm
From: Seebs


On 2010-04-20, christian.bau <christian.bau@cbau.wanadoo.co.uk> wrote:
> On Apr 20, 6:54�pm, spinoza1111 <spinoza1...@yahoo.com> wrote:
>> "Edward G. Nilges is a Usenet Kook. An epic kook. He has an astounding
>> talent for getting things wrong, really beyond anything you're likely
>> to anticipate. It is a wonder and a miracle to behold."

> I agree one hundred percent.

I'd just like to clarify something for the folks in CLC:

I specifically wrote that, knowing that he searches for references to
himself, in the hopes that it would get him to come interact with me
somewhere where it's less of a disruption for the rest of you all. With
any luck, he can be induced to spend time talking to people who care,
or who find him amusing, whichever comes first.

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


== 2 of 9 ==
Date: Tues, Apr 20 2010 6:25 pm
From: rigs


Such quick Google work is a sign of the high level narcissism found
only in the finest of internet kooks.


== 3 of 9 ==
Date: Tues, Apr 20 2010 6:51 pm
From: Richard Heathfield


spinoza1111 wrote:
> Seebach has lost the argument on two major points this past week:
>
> * He was forced to concede that void main() is standard C in a
> freestanding environment,

I don't recall him ever denying it.


which completely undercuts 15 years of
> saying that it's not standard C
>
> * He was forced to withdraw "C: the Complete Nonsense" because of
> complaints,

Wrong. It's still up. So is an updated version (the original has been
left for comparison). The updated version reads in part: "a careful
study of the 4th edition of Schildt's C: The Complete Reference reveals
that, while he may have fixed a few problems after being called on them,
he continues to be unwilling or unable to correctly explain many of the
basics of effective and correct C programming."

Hardly a withdrawal.

<nonsense snipped>

> Yet in a court of law he'd naturally be asked to reconcile these
> statements:
>
> * At http://www.freethought-forum.com/forum/showthread.php?p=833865:
> "Edward G. Nilges is a Usenet Kook. An epic kook. He has an astounding
> talent for getting things wrong, really beyond anything you're likely
> to anticipate. It is a wonder and a miracle to behold."
>
> * At http://www.seebs.net/c/c_tcn4e.html: "I must of course credit
> Edward Nilges, whose tireless crusade against the deficiencies of the
> previous version made it clear that a more complete treatment was
> needed. "

A comparison of the two versions will show that, as a direct result of
your intervention, CTCN became far more critical of CTCR than had
previously been the case. You have, therefore, succeeded in increasing
the amount of criticism levelled at Schildt's works. If that was your
intent, you chose a very strange way of going about it.

> Note that attorneys are like cops. Literal-minded and deaf to
> sarcastic overtones as regards a written document.

But they are perfectly capable of reading the Usenet thread in which you
carried out your crusade, and perfectly capable of deducing that you're
an idiot.

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


== 4 of 9 ==
Date: Tues, Apr 20 2010 7:00 pm
From: spinoza1111


On Apr 21, 7:33 am, Seebs <usenet-nos...@seebs.net> wrote:
> On 2010-04-20, christian.bau <christian....@cbau.wanadoo.co.uk> wrote:
>
> > On Apr 20, 6:54 pm, spinoza1111 <spinoza1...@yahoo.com> wrote:
> >> "Edward G. Nilges is a Usenet Kook. An epic kook. He has an astounding
> >> talent for getting things wrong, really beyond anything you're likely
> >> to anticipate. It is a wonder and a miracle to behold."
> > I agree one hundred percent.
>
> I'd just like to clarify something for the folks in CLC:
>
> I specifically wrote that, knowing that he searches for references to
> himself, in the hopes that it would get him to come interact with me
> somewhere where it's less of a disruption for the rest of you all.  With
> any luck, he can be induced to spend time talking to people who care,
> or who find him amusing, whichever comes first.

Actually, since over the past few months I've relearned C, I find it
more amusing to stay here and watch you and Keith Thompson turn away
genuine questions, claiming that the OP has come to the wrong place,
because you can't answer the question.

Your answer to the OP with a question about YACC was hilarious, since
a competent C programmer will know enough YACC to see that his problem
was that his professor doesn't know how to implement operator
precedence in a formal grammar (another programmer with no computer
science?). I used yacc with C years ago and realized it was better to
write one's own generator (did so in Rexx) or write the parser
manually.

Kiki also tried to get rid of the OP whose call to odbc was pretty
obviously wrong.

As to doing us a favor: I don't believe you, based on your track
record. You like to ensure that a person's name is replicated and
becomes a byword, because you're incompetent as a programmer and this
in my experience how incompetent programmers flourish.
>
> -s
> --
> Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

== 5 of 9 ==
Date: Tues, Apr 20 2010 7:03 pm
From: Richard Heathfield


Richard Heathfield wrote:
> spinoza1111 wrote:
>> Seebach has lost the argument on two major points this past week:
>>
>> * He was forced to concede that void main() is standard C in a
>> freestanding environment,
>
> I don't recall him ever denying it.

I need to rephrase that. I read the above too quickly.

void main is only "standard C in a freestanding environment" in the
sense that the Standard does not forbid void main in such an
environment. It is this fact (the lack of prohibition) which I don't
recall Seebs ever denying.

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


== 6 of 9 ==
Date: Tues, Apr 20 2010 7:11 pm
From: Ian Collins


On 04/21/10 01:51 PM, Richard Heathfield wrote:
> spinoza1111 wrote:
>
>> Note that attorneys are like cops. Literal-minded and deaf to
>> sarcastic overtones as regards a written document.
>
> But they are perfectly capable of reading the Usenet thread in which you
> carried out your crusade, and perfectly capable of deducing that you're
> an idiot.

They will then send you a hefty bill for discovering the blindingly obvious.

--
Ian Collins


== 7 of 9 ==
Date: Tues, Apr 20 2010 7:20 pm
From: Seebs


On 2010-04-21, Richard Heathfield <rjh@see.sig.invalid> wrote:
> spinoza1111 wrote:
>> Seebach has lost the argument on two major points this past week:
>> * He was forced to concede that void main() is standard C in a
>> freestanding environment,

> I don't recall him ever denying it.

Indeed, I even defended Nilges on that point -- not that it's
relevant, because Schildt was unambiguously writing about a hosted
environment:

* He never refers to the distinction at all.
* He uses <stdio.h> functionality, which is only meaningful in a hosted
environment.
* He fixed the error in the 4th edition.

>> Yet in a court of law

Please. My lawyer needs the lulz.

>> he'd naturally be asked to reconcile these
>> statements:

I do not share your optimism. A lawyer dumb enough to ask a question
that stupid is, in terms of sheer lulz, beyond the dreams of avarice.

>> Note that attorneys are like cops. Literal-minded and deaf to
>> sarcastic overtones as regards a written document.

> But they are perfectly capable of reading the Usenet thread in which you
> carried out your crusade, and perfectly capable of deducing that you're
> an idiot.

Sure, but that statement is fractally wrong anyway.

1. Lawyers often have a great sense of humor.
2. Who cares whether attorneys get sarcasm? Decisions are made
by judges and juries.
3. Says a judge:

Despite the continued shortcomings of Plaintiff's supplemental
submission, the Court commends Plaintiff for his vastly improved
choice of crayon -- Brick Red is much easier on the eyes
than Goldenrod, and stands out much better amidst the mustard
splotched about Plaintiff's briefing. But at the end of the day, even
if you put a calico dress on it and call it Florence, a pig is still
a pig.
4. It doesn't matter whether the judge, or any attorney, thinks it's
funny; at most, what would matter is whether *I* appeared to think it
was funny, and I do not believe I would have any trouble convincing
a jury of my peers that I have a, shall we say, broad-ranging sense
of humor.
5. Imagine that all of the above don't apply, and I can't reconcile the
statements. So what?

Seriously, though, Nilges, I waved your magic search terms around on that
forum in the hopes that you'd come over there and play.

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


== 8 of 9 ==
Date: Tues, Apr 20 2010 8:12 pm
From: Peter Nilsson


Seebs <usenet-nos...@seebs.net> wrote:
> ...Seriously, though, Nilges, I waved your magic search
> terms around on that forum in the hopes that you'd come
> over there and play.

But you announced it in this forum, clearly not willing to
take his googling success for granted; leaving the door open
to continue the noise in clc.

--
Peter


== 9 of 9 ==
Date: Tues, Apr 20 2010 8:13 pm
From: Peter Nilsson


Ian Collins <ian-n...@hotmail.com> wrote:
> Richard Heathfield wrote:
> > spinoza1111 wrote:
> > > Note that attorneys are like cops. Literal-minded and
> > > deaf to sarcastic overtones as regards a written document.
> >
> > But they are perfectly capable of reading the Usenet thread
> > in which you carried out your crusade, and perfectly capable
> > of deducing that you're an idiot.
>
> They will then send you a hefty bill for discovering the
> blindingly obvious.

This incessant and habitual need to reaffirm opinions that
have been made many times over *years*, not just months, is
beyond tiresome. It is *no less* damaging to clc than the
troll's habitual reaffirmations of solidarity, since the
motivation and outcomes are the precisely the same.

--
Peter

==============================================================================
TOPIC: Tibco Administrator , Orlando, Florida
http://groups.google.com/group/comp.lang.c/t/4714bb4d2597f343?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 20 2010 4:35 pm
From: Seebs


On 2010-04-20, Ersek, Laszlo <lacos@caesar.elte.hu> wrote:
> C'mon, at least get your spam right, that's "TIBCO Hawk".

Interesting trivia point: Every recruiter I've ever talked to who spammed
usenet was also a scammer at some other level. I would certainly never,
under any conceivable circumstances, do business with one.

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

==============================================================================
TOPIC: seebs/schildt
http://groups.google.com/group/comp.lang.c/t/0c84debf9a4f144b?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 20 2010 6:18 pm
From: Richard Heathfield


spinoza1111 wrote:
> On Apr 20, 3:39 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> spinoza1111wrote:
>>
<snip>

>>> Two half-literate spelling errors
>> Anyone who spells "desperate" with two 'a's is in no position to
>> complain about illiteracy.
>
> Torvalds' spelling errors are part of a larger picture

Special pleading. His spelling errors make him half-literate, but yours
are okay because it's you making them. Sheer hypocrisy.

<snip>

> We all have online dictionaries, creep.

It doesn't show.

<snip>

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

==============================================================================
TOPIC: OT: [NILGES] portability [Was: In the Matter of Herb Schildt:...]
http://groups.google.com/group/comp.lang.c/t/caf17fab4e7d8530?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Apr 20 2010 6:43 pm
From: Richard Heathfield


spinoza1111 wrote:
> On Apr 20, 7:06 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> spinoza1111wrote:
>>
<snip>
>>
>>> Richard, your hatred of teachers and professors
>> You are mistaken. Again.
>>
> Oh, I'm sure you love "the right kind" of teachers...the ones who
> agree with you.

Actually, the teachers I like best are those who correctly teach me
useful (or, at the very least, interesting) stuff. A teacher who is
capable of changing my mind is (normally) a good teacher. (I add
"normally" because I have rather a spectacular counterexample in mind,
but we're way too far off-topic as it is.)

<nonsense snipped>

ObC (sort of): in late 1998, I had become established in a particular
online discussion channel as a useful guy to know if one wanted help
with C. On one occasion, however, I posted an example program that
contained an egregious (and common) error; I didn't know it was an error
because, in that respect at least, I had been misled by my C teachers
almost a decade earlier. One observer spotted the error, and raised it
with me quietly via a private channel. He said that he was almost sure I
was mistaken. I dug out K&R to prove him wrong (as one does), but - to
my astonishment - I couldn't find any reference to my (erroneous)
construct. The best argument I could construct was "it doesn't say you
can't", which is hardly a solid recommendation. After looking into the
matter in more detail, I came to three conclusions: (i) he was right,
and I was wrong; (ii) I needed to take a long hard look at my
"knowledge" of the language, for who knows what else I had been
mistaught? and (iii) he was a great teacher.

Several years later, I bumped (metaphorically) into him again, and he
asked me a question about C that was troubling him. I answered it, but
then reminded him of the above episode. He replied that his intention in
correcting me back then was to set me on the road to becoming a C
expert, so that he'd have a C expert handy when he needed one.

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


== 2 of 2 ==
Date: Tues, Apr 20 2010 6:45 pm
From: Seebs


On 2010-04-21, Richard Heathfield <rjh@see.sig.invalid> wrote:
> Several years later, I bumped (metaphorically) into him again, and he
> asked me a question about C that was troubling him. I answered it, but
> then reminded him of the above episode. He replied that his intention in
> correcting me back then was to set me on the road to becoming a C
> expert, so that he'd have a C expert handy when he needed one.

That's amusing. $dayjob has both me and Chris Torek, so we are pretty
well set for C experts. (Trivia point, he's one of the people who set
me on the course to actually knowing C.)

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

==============================================================================
TOPIC: Generic programming in C
http://groups.google.com/group/comp.lang.c/t/efedbc3e3c37ccc1?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 20 2010 6:56 pm
From: Richard Heathfield


Nick wrote:
<snip>

> I am used to people using functions that write unknown length strings
> into string pointers, and what happens when they do.

I am not an lcc-win32 user so my reply is based purely on what I've read
in this thread. It seems that JN has provided a mechanism for
establishing the required length of the buffer, so that you can call it
once to get the buffer length (a step that you can skip if you already
know that length), and then call it to do the actual work. That seems to
me to be a perfectly reasonable interface. In that regard, JN's strrepl
is no less safe than strcpy. (In other regards, I wouldn't know; like I
said, I'm not an lcc-win32 user.)

<snip>

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

==============================================================================
TOPIC: Question
http://groups.google.com/group/comp.lang.c/t/0643f4ad3c239efe?hl=en
==============================================================================

== 1 of 6 ==
Date: Tues, Apr 20 2010 7:26 pm
From: spinoza1111


On Apr 20, 11:03 pm, enam <gogonch...@gmail.com> wrote:
> 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/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.


== 2 of 6 ==
Date: Tues, Apr 20 2010 7:28 pm
From: spinoza1111


On Apr 20, 11:46 pm, Seebs <usenet-nos...@seebs.net> wrote:
> On 2010-04-20, enam <gogonch...@gmail.com> wrote:
>
> > 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
> --
> Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

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.


== 3 of 6 ==
Date: Tues, Apr 20 2010 8:00 pm
From: Richard Heathfield


spinoza1111 wrote:

<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


== 4 of 6 ==
Date: Tues, Apr 20 2010 8:02 pm
From: Richard Heathfield


spinoza1111 wrote:
> On Apr 20, 11:46 pm, Seebs <usenet-nos...@seebs.net> wrote:
>> On 2010-04-20, enam <gogonch...@gmail.com> wrote:
>>
>>> 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.
>
> 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.

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.

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


== 5 of 6 ==
Date: Tues, Apr 20 2010 8:19 pm
From: Ian Collins


On 04/21/10 03:00 PM, Richard Heathfield wrote:
> spinoza1111 wrote:
>
>> 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.

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


== 6 of 6 ==
Date: Tues, Apr 20 2010 8:25 pm
From: Peter Nilsson


spinoza1111 <spinoza1...@yahoo.com> wrote:
> 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.

<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


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en

To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate