for and arrays

N

Nick Keighley

propably not. I'm sure he sincerly believes he's right

The point is that it would.

here I have to disagree. There is no way you can know this.
Unless you have some deep insight into bill's psychology
I don't see how *anyone* (at least on comp.lang.c) can
work out what would help bill. For this reason I didn't
contradict you when you suggested examining the data structures and
program flow using a debugger. Normally I don't see the point
(yep, we disagreed on this before); but in bills' case who then
hell can tell what *might* help. May be he'll play around in gdb
and click! the light goes on. I must admit the output from raw
gdb looks a bit messy (and bill confuses easily). Mightn't a gui
based one be better for him? ddd actually draws pictures of data
structures.

He just seems to lack some basic machinary or insight into
how imperetive programming languages work. Maybe he should
learn assembler. Maybe he should learn prolog. I just don't know.

*I* think (and I have nearly as much doubt about this as your
debugger-solves-everything approach), he lacks the ability to plainly
state what he is trying to do. I've tried english, pseudo-code
and even assembler (when I was starting some insight into the
hardware was fruitful- but people vary). if you can't say
what you want how can you ever know you've acheived it? I think
some people are just mentally unequipped to program. Bill may
be one of them.

You might not see it. But you are looking
from a different, possibly equally valid, angle. I have spent a lot of
time with trainees

ah. I've spent *some* time with trainees- and not recently

and I have seen people almost as stuck as Bill.
wow

Best
way is to get them into the memory and SEE things as the program
steps. To see the string. To see the chars. To see the end of string
marker.

And if you think this advice is trolling then I am surprised.


In some cases I take that stance. For example when someone assures me
they can debug 50,000 lines of foreign c code quicker from a printout
than from using an industry strength debugger. Those kind of things that
only get spouted in clc. it is nonsense. Can someone in the world? I
have no doubt someone can. Would we recommend that to someone like Bill
because some Indian Guru can? No we would not. Would we guess that 99%
can because Heathfield once spotted a bug on page one 10 years ago? No
we would not. We would advise sensible procedures to approach the
problem.


My position here is that its the old seed versus crops thing with
Bill. Get him to teach himself the basic types. Feeling them with a
debugger is a great way. He seems to be as clueless as 6 months ago and
need to get his hands dirty.

he certainly needs *something* to get him out of his current
"methodology".
"I wonder if a for-loop would be useful here". I've floundered
but never to that extent!

I've suggested paper execution (which I suppose is a manual way
of single stepping a debugger).
Pasting in solutions for him is not helping
him -
agreed


if anything it is hindering him since he then mistakenly thinks he
knows why something is working. He doesn't. He needs to follow the
tutorial and learn how to examine his own programs for now. More
complicated things can follow.

<snip>

--
Nick Keighley

"Perilous to us all are the devices of an art deeper than we possess
ourselves."
Gandalf The Grey (discussing Windows NT)
 
N

Nick Keighley

No I have no idea. That looks like garbage on your printout.

yes. Now think why would the program keep printing?
What tells it when to stop?

Think about it.
 
R

Richard

Nick Keighley said:
propably not. I'm sure he sincerly believes he's right



here I have to disagree. There is no way you can know this.

No. Not 100%. But in a group of professionals I tend not to add caveats
to everything.
Unless you have some deep insight into bill's psychology
I don't see how *anyone* (at least on comp.lang.c) can
work out what would help bill. For this reason I didn't

Look. When I say "I know" I clearly mean "my experience suggests that it
almost certainly will help". Nothing is 100%.
contradict you when you suggested examining the data structures and
program flow using a debugger. Normally I don't see the point
(yep, we disagreed on this before); but in bills' case who then

Yes you have mentioned you do not see the point. I find this rather
strange and wonder about what experience you have had with such tools
which have left you seeing them as so useless. A lot of the feedback I
have read in c.l.c suggests to me that some the regulars (not including
you necessarily) simply have zero clue what a modern debugger can do and
how using it can dramatically shorten their development cycle. it is not
only there to "find bugs". It is there to stop the system when certain
criteria are met. Allows you to modify run time variables to "push"
certain extreme states you might want to give a test run. etc etc etc.

http://dirac.org/linux/gdb/01-Introduction.php#whatisadebugger

But to be blunt : I can see NO negative aspects of someone like Bill
examining c strings and arrays etc in a debugger. The data examine
commands will display the types, lengths etc. he can see and modify the
data. It can be nothing but beneficial. Staring at other peoples
solutions on "paper" is clearly doing him no good whatsoever.
hell can tell what *might* help. May be he'll play around in gdb
and click! the light goes on. I must admit the output from raw
gdb looks a bit messy (and bill confuses easily). Mightn't a gui
based one be better for him? ddd actually draws pictures of data
structures.

And there are other debuggers too. It does not have to be gdb. The point
is simply that getting "down and dirty" will help. It can do NO
harm. And that is the bottom line for me.
 
R

Richard

Nick Keighley said:
yes. Now think why would the program keep printing?
What tells it when to stop?

Think about it.

Maybe even get a debugger to show the "string" a?

Then wonder why. Then look up what a c string is. Then check his "a"
meets that criteria? Maybe even use a debugger to add a 0 in the array
of chars somewhere and then print its value again? All done in a matter
of seconds with no recompilation required.

Not much thinking - more doing. Touchy feely.
 
D

Default User

Nick said:
propably not. I'm sure he sincerly believes he's right

I think the evidence is well against you. Whatever his motivations,
he's made it clear that he wants to disrupt the newsgroup through his
postings.




Brian
 
R

Richard

Default User said:
I think the evidence is well against you. Whatever his motivations,
he's made it clear that he wants to disrupt the newsgroup through his
postings.




Brian

You continue to add nothing to the thread. Why is that?

Is the totality of your knowledge only to wag your finger and tell
people what they can post and they can post to?

Possibly you would like to dissect what I said, not what you think I
said, and explain why any of it is NOT good advice for a new C
programmer so obviously confused by the parlance used here.
 
B

Ben Bacarisse

Richard said:
Maybe even get a debugger to show the "string" a?

He won't see anything wrong. His data is terminated. he has said
so. The program is wrong but the data happens to be correct. A
debugger won't help here. I've said it before but I need to keep
saying it in case he tries and wonders why everything is OK. The
output above is from *my system* not his.
 
R

Richard

Richard Heathfield said:
Nick Keighley said:


Why are sure of that? The frequency of his exaggerations, his incorrect
claims, his hypocritical complaints about those who make certain kinds of
complaints, his mis-characterisations and mis-representations of other
people's positions, and his dabblings with other trolls in the group is
way too high to be explained by stupidity.

I have applied Hanlon's Razor, and found it blunt. The guy's a troll.

<snip>

As I pointed out, my view that you are an obnoxious egomaniac does not,
in any shape or form, make me a troll.

You take yourself far too seriously when it suits you. You are not the
group moderator. You are not indispensable. And you are not particularly
special when it comes to help new C programmers since you're so full of
your own self importance you find it almost impossible to bring things
down to a level that the new, and often panicking, programmer can come
to deal with. Other, more open, contributors make this a far nicer group
than you could ever hope to with your mealy mouthed word games and
pedantic nit picking.
 
R

Richard

Ben Bacarisse said:
He won't see anything wrong. His data is terminated. he has said

Not in the code directly linked upthread it wasn't. or the output would
not be as indicated above.
so. The program is wrong but the data happens to be correct. A
debugger won't help here. I've said it before but I need to keep
saying it in case he tries and wonders why everything is OK. The
output above is from *my system* not his.

But once more : my recommendations are about him getting a feeling for
the data. Even today we have the ridiculous nit picking about strings
not being a type but a "kind of" character array. No wonder so many
nOObs leave this place with a headache.
 
K

Keith Thompson

Richard said:
Richard Heathfield said:
Nick Keighley said:
Riley is a troll.

propably not. I'm sure he sincerly believes he's right
[...]

I have applied Hanlon's Razor, and found it blunt. The guy's a troll.

<snip>

As I pointed out, my view that you are an obnoxious egomaniac does not,
in any shape or form, make me a troll.
[...]

That's absolutely correct. It's not your opinion of Richard
Heathfield that makes you a troll. (Nobody has said that it is.)
 
S

Serve Lau

Ben Bacarisse said:
I don't understand this. If you think Bill is clever fiction, why are
you replying with serious suggestions (see below)? If you think he is
genuinely struggling to learn, then why laugh at his attempts. It
seems cruel.

lol cruel. If Bill's not a troll, he's REALLY masochistic! But I'm leaning
towards he's a troll but then a very funny and smart one.
 
A

Antoninus Twink

For the record, I don't use the term myself. It is too easy to throw
around and too hard to decide in all the cases where it matters.

A sensible position. One man's troll is another man's Default Loser.
 
A

Antoninus Twink

I think the evidence is well against you. Whatever his motivations,
he's made it clear that he wants to disrupt the newsgroup through his
postings.

"Disrupt the newsgroup", huh? Why don't you count the number of positive
contributions of information and suggestions and answers to newbies'
questions from your trio of "trolls" in the last month, and compare it
to the number of times *you*'ve tried to sow genuine disruption in the
group by stirring up endless debates and ill-feeling about who is and
isn't a "troll"?
 
B

Bill Cunningham

Mark L Pappin said:
Bill, can you see the difference in structure between the template I
suggested and what you've got here?

I suggested

for (A ; B ; C) {
D
}
E

and you have written

for (A ; B ; C)
F

I suggested that you print the value of i and the space within the
body of the loop, and then print the newline after the loop finishes.
You printed each of those 3 things within the body of the loop. You
also used the "no curly brackets" form of the loop and no indentation
which may in fact be contributing to your confusion over what happens
when.

I would recommend that until your skill level goes way up you
should use curly brackets around the body of every loop, conditional,
etc. that you write - this will help to reinforce the idea of
structure for you. Thus, always write

for (A ; B ; C) {
D
}
E

and never

for (A ; B ; C)
D
E

even if 'D' is just a single statement.

Just in case you're confused about what the 'for' construct does: the
above will first do 'A', then it will test if 'B' is zero - if it is,
then the loop finishes, but if not then it will do 'D', and then 'C',
and back to the test. After the loop finishes (that is, 'B' is found
to be equal to zero), then 'E' will be run. (If this is unclear, tell
me - otherwise, I will assume that you understand it in full.)


Likewise, stick with

if (A) {
B
}
else {
C
}

(once we start writing code using 'if') instead of

if (A)
B
else
C

For the purposes of this tutorial I recommend that you indent your
code as I have done here, and at least 2 spaces per level. After
you're more competent at writing actual code is the time for you to
worry about the pros and cons of different indentation styles - right
now we need to reinforce the structure of the code inside your head,
and keep it understandable for those of us who have to read what you
write.



I see that you've later realized why your output appears in a vertical
column instead of a horizontal row. Please have another go at posting
a complete program that prints a single line containing the digits 0
through 6 inclusive, separated by spaces, followed by a newline
character. Once you've managed to regurgitate that (and that is all
this initial bit will be: learning some common patterns by rote until
you have them internalized), I'll give you another couple of problems
to work on, that use what we've done so far and add a little bit at a
time to it.

mlp

I think I might have it right now Mark.
#include <stdio.h>

int main(void) {
int i;
for (i=0;i<7;i++) {
printf("%i",i);
printf(" ");
}
printf("\n");
return 0;
}

Bill
 
M

Mark L Pappin

I think I might have it right now Mark.
#include <stdio.h>

int main(void) {
int i;
for (i=0;i<7;i++) {
printf("%i",i);
printf(" ");
}

You have this closing-curly-bracket lined up with the start of each
line _within_ the block.
I recommended (by example) that you line up each closing-curly-bracket
with the start of the line _introducing_ the block.

I requested that for the purposes of this tutorial you follow the
indentation scheme I've used. Is there some reason you have not done
so?

You may certainly choose any scheme you like, but I thought I had made
it clear
- I believe that sticking strictly to the layout I use here will
reinforce concepts that are important to programming in C;
and
- if you don't follow my recommendations and can't back up any
deviations with sound argument then the tutorial stops.
printf("\n");
return 0;
}

Other than the [some might say minor] indentation issue, this is
exactly what I had hoped you would produce. So, on with the tutorial.

3c. Modify the above program to print the number and the space with a
single call to 'printf()' instead of two calls.


4a. Write a program to print 7 lines, each containing the line number
(start at 0), the square of the line number, and the cube of the line
number, separated by spaces.

(The square of a number is that number multiplied by itself.
The cube of a number is the number multiplied by its square.)


4b. Modify your answer for 4a to print 11 lines.

(If this requires more than changing a '7' to an '11', go back and
find another way to answer 4a, then continue.)


4c. Modify your answer for 4b to print at the end of each line another
space and the maximum value of an 'int'.

(Hint: lines like
#include <limits.h>
printf(" %d",INT_MAX);
will be involved.)


4d. Can you figure out what maximum number of lines the program could
print and still produce correct values for the square and cube? Could
that maximum be made larger, and how?


mlp
 
B

Bill Cunningham

You have this closing-curly-bracket lined up with the start of each
line _within_ the block.
I recommended (by example) that you line up each closing-curly-bracket
with the start of the line _introducing_ the block.

I requested that for the purposes of this tutorial you follow the
indentation scheme I've used. Is there some reason you have not done
so?

I used a braces scheme I'm used to. Maybe I didn't understand. How
exactly would you again like me to use the scheme you requested ? I will
look back at previous posts to see if I missed something.

Bill
 
S

santosh

Richard wrote:

The issue is for Bill to understand the data. Nothing more. Nothing
less. We keep hearing "I dont know spaces", "I dont know string" etc
etc. Its tiresome. He needs to do some spadework.

It's my personal opinion that Bill C has become a sort of collective
obsession of CLC. I'm pretty sure he is a troll. Anyone who genuinely
has the sort of problems that he seems to display would have given up
on programming long back, or would be well advised to do so. If he
needs some sort of recreational therapy (assuming for the moment that
he *is* a genuine case), then there are plenty of better hobbies to
chose (in the sense that it would be better for *him* ) from than
grappling with C. Programming is hard enough for a normal person, I
don't know why someone like Bill must punish himself upon it.

Of course having said all this I have simply concluded that he is a
troll. The presence of the string

Message-ID: <P56jk.199$JH5.174@trnddc06>

in his headers leads me believe he is having a good laugh at the
spectacle of a whole group running around him.
 
C

Chris Thomasson

santosh said:
Richard wrote:



It's my personal opinion that Bill C has become a sort of collective
obsession of CLC. I'm pretty sure he is a troll. Anyone who genuinely
has the sort of problems that he seems to display would have given up
on programming long back, or would be well advised to do so. If he
needs some sort of recreational therapy (assuming for the moment that
he *is* a genuine case), then there are plenty of better hobbies to
chose (in the sense that it would be better for *him* ) from than
grappling with C. Programming is hard enough for a normal person, I
don't know why someone like Bill must punish himself upon it.

Of course having said all this I have simply concluded that he is a
troll. The presence of the string

Message-ID: <P56jk.199$JH5.174@trnddc06>

in his headers leads me believe he is having a good laugh at the
spectacle of a whole group running around him.

Bill probably works for Microsoft.
 
M

Mark L Pappin

Bill Cunningham said:
I used a braces scheme I'm used to. Maybe I didn't understand. How
exactly would you again like me to use the scheme you requested ?

I recommended (and provided you with several templates of)

for (...) {
X
}

You wrote

for (...) {
X
}

which would be fine except for your inconsistency with the block which
is the function body - I recommended and you wrote

int main(void) {
Y
}

In both cases the block is in a sense the "body" of the section of
code of which the first line is the "head", that is, the block has the
same subordinate relationship to the first line, and it is this common
structure that I want you to reinforce. You say that you have a
learning difficulty - well, I want to help you overcome that, and the
technique I have seen used most successfully in such cases is drill,
repetition, rote-learning.

So, I intend to have you marching up and down this programming parade
ground with your indentation scheme freshly pressed and your data
structures shining, soldier. Then when the forces of evil come at you
in the form of a problem specification you will not have to even think
about where to put a curly bracket, or wonder if your standard library
routine will work - you will write the fundamentals as a reflex.

It is now your call:

- pick an indentation scheme for a defensible reason ("Bill's used to
it" is not defensible here; "Mark recommended it" is), use it
consistently, and we continue the tutorial; or

- do something else, and I'll get on with my life no longer encumbered
by you.

mlp
 
K

Keith Thompson

santosh said:
Of course having said all this I have simply concluded that he is a
troll. The presence of the string

Message-ID: <P56jk.199$JH5.174@trnddc06>

in his headers leads me believe he is having a good laugh at the
spectacle of a whole group running around him.

I don't understand. What is it about the Message-ID that causes you
to reach that conclusion?
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top