Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

for and arrays

2 views
Skip to first unread message

Bill Cunningham

unread,
Jul 22, 2008, 6:15:52 PM7/22/08
to
I understand this code.

int a[5];
int b;
for (b=0;b<5;b=b+1)
int a[b];

This should take every element of the array a and set it to 1,2,3,4,5.
Great. Now for the big question. How would you work this?

int a [5][3];

And make the first element of 5 all zeros and the second element of 3 equal
to 1,2,3 ? I don't know how to work with a 2 dimensional array.

Bill


Ben Bacarisse

unread,
Jul 22, 2008, 6:34:13 PM7/22/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> I understand this code.
>
> int a[5];
> int b;
> for (b=0;b<5;b=b+1)
> int a[b];

Did you try?

> This should take every element of the array a and set it to 1,2,3,4,5.
> Great.

No, a loop that "sets" things will usually have an assignment in its
body.

> Now for the big question. How would you work this?
>
> int a [5][3];
>
> And make the first element of 5 all zeros and the second element of 3 equal
> to 1,2,3 ? I don't know how to work with a 2 dimensional array.

I'd stick with 1 dimensional ones. If you are in this for the
challenge of learning C, then it is much better to master the easy
bits before moving on. If you have some objective in mind (i.e. you
want to write some specific program) then you should pick a language
with fewer pitfalls and peculiarities than C. In particular,
interpreted languages let you learn by trying things out which, I
suspect, is a style that would suit you.

--
Ben.

Bill Cunningham

unread,
Jul 22, 2008, 6:46:45 PM7/22/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87tzeh1...@bsb.me.uk...

> "Bill Cunningham" <nos...@nspam.com> writes:
>
>> I understand this code.
>>
>> int a[5];
>> int b;
>> for (b=0;b<5;b=b+1)
>> int a[b];
>
> Did you try?

Well I tried and it compiled with no errors. Or atleast compiled anyway.
Yes this is an excercise to learn. All I do is an excercise to learn. What
if one had an array of 500 ints and had the simple task of setting them
1-500? How's this for another take.

int a[10];
int b;
for (b=0;b<10;b++) {

a[ b=b+1];
}


Bill


Ben Bacarisse

unread,
Jul 22, 2008, 7:30:29 PM7/22/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
> news:87tzeh1...@bsb.me.uk...
>> "Bill Cunningham" <nos...@nspam.com> writes:
>>
>>> I understand this code.
>>>
>>> int a[5];
>>> int b;
>>> for (b=0;b<5;b=b+1)
>>> int a[b];
>>
>> Did you try?
>
> Well I tried and it compiled with no errors. Or atleast compiled
> anyway.

You must have found out by now that a program that compiles is like an
essay the spell-checks. It does not mean you've answered the question.



> Yes this is an excercise to learn.

Compiling it is not enough, then. The wonderful thing about
programming is that your program can tell you if you've got it right.

> All I do is an excercise to learn. What
> if one had an array of 500 ints and had the simple task of setting them
> 1-500? How's this for another take.
>
> int a[10];
> int b;
> for (b=0;b<10;b++) {
>
> a[ b=b+1];
> }

Let's assume that you intended to write a[500] rather than a[10]. You
need to move one character characters to turn the above into
a program that does what you want, but can you see which character
needs to move at to where?

[I still think that you should learn an interpreted language.]

--
Ben.

Keith Thompson

unread,
Jul 22, 2008, 7:40:36 PM7/22/08
to
"Bill Cunningham" <nos...@nspam.com> writes:
> I understand this code.

No, I'm afraid you don't.

> int a[5];
> int b;
> for (b=0;b<5;b=b+1)
> int a[b];
>
> This should take every element of the array a and set it to 1,2,3,4,5.

You seem to be thinking that the line "int a[b];" assigns a value to
an element of a. In fact, it doesn't do anything at all like that.
Knowing what it actually does won't help you, so please ignore the
following. (It declares a VLA which hides the declaration of a.)

Just this once, I'll give you a freebie. If you want to set the
elements of a to 1, 2, 3, 4, 5, here's one way to do it:

int a[5];
int i;
for (i = 0; i < 5; i ++) {
a[i] = i + 1;
}

> Great. Now for the big question. How would you work this?
>
> int a [5][3];
>
> And make the first element of 5 all zeros and the second element of 3 equal
> to 1,2,3 ? I don't know how to work with a 2 dimensional array.

You don't even understand what a 2 dimensional array is. Your
question assumes that it's a 5-element array followed by a 3-element
array. It isn't. It's a 5-element array, each of whose elements is a
3-element array of ints, for a total of 15 (5*3) ints.

Here's a conceptual picture of your one-dimensional array, where each
'#' represents an element that can hold an int value:

+-+-+-+-+-+
|#|#|#|#|#|
+-+-+-+-+-+

And here's a corresponding picture for your "int a[5][3];":

+-+-+-+
|#|#|#|
+-+-+-+
|#|#|#|
+-+-+-+
|#|#|#|
+-+-+-+
|#|#|#|
+-+-+-+
|#|#|#|
+-+-+-+


But you shouldn't even be thinking about 2-dimensional arrays until
you have a firm grasp on 1-dimensional arrays.

--
Keith Thompson (The_Other_Keith) ks...@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"

Bill Cunningham

unread,
Jul 22, 2008, 10:19:29 PM7/22/08
to

"Keith Thompson" <ks...@mib.org> wrote in message
news:lnr69li...@nuthaus.mib.org...

> You don't even understand what a 2 dimensional array is. Your
> question assumes that it's a 5-element array followed by a 3-element
> array. It isn't. It's a 5-element array, each of whose elements is a
> 3-element array of ints, for a total of 15 (5*3) ints.

I understand if I am correct that each of the 5 elements have 3
elements. Yes. What I didn't understand was

a[i]=i+1;

Bill


Barry Schwarz

unread,
Jul 23, 2008, 1:22:07 AM7/23/08
to
On Tue, 22 Jul 2008 22:15:52 GMT, "Bill Cunningham" <nos...@nspam.com>
wrote:

>I understand this code.

You are not even close as others have pointed out.

>
>int a[5];
>int b;
>for (b=0;b<5;b=b+1)
>int a[b];
>
> This should take every element of the array a and set it to 1,2,3,4,5.
>Great. Now for the big question. How would you work this?
>
>int a [5][3];
>
>And make the first element of 5 all zeros and the second element of 3 equal

What do you think the phrase "first element of 5" means? What about
"the second element of 3"? How many elements to you think this 2D
array has?

>to 1,2,3 ? I don't know how to work with a 2 dimensional array.

Don't even try till after you understand 1D arrays.


Remove del for email

Barry Schwarz

unread,
Jul 23, 2008, 1:22:07 AM7/23/08
to
On Tue, 22 Jul 2008 16:40:36 -0700, Keith Thompson <ks...@mib.org>
wrote:

>"Bill Cunningham" <nos...@nspam.com> writes:
>> I understand this code.
>
>No, I'm afraid you don't.
>
>> int a[5];
>> int b;
>> for (b=0;b<5;b=b+1)
>> int a[b];
>>
>> This should take every element of the array a and set it to 1,2,3,4,5.
>
>You seem to be thinking that the line "int a[b];" assigns a value to
>an element of a. In fact, it doesn't do anything at all like that.
>Knowing what it actually does won't help you, so please ignore the
>following. (It declares a VLA which hides the declaration of a.)

Since there are no braces around the statement, it is a constraint
violation in C89 since declarations must precede statements. Even in
C99 it should be a duplicate definition of a.


Remove del for email

Keith Thompson

unread,
Jul 23, 2008, 2:43:35 AM7/23/08
to

It's also a constraint violation in C89 because it's a VLA. But I
didn't want to go into too much detail about why it's wrong. The way
to transform that into what Bill intended is to delete it and write a
correct line.

Bill Cunningham

unread,
Jul 23, 2008, 5:28:43 PM7/23/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87prp51...@bsb.me.uk...

> [I still think that you should learn an interpreted language.]
>

I've come so far with C now why stop ? Though I have even more to learn.
This C syntax is confusing. Bash and Perl are interesting though.

Bill


Richard Heathfield

unread,
Jul 23, 2008, 5:57:36 PM7/23/08
to
Bill Cunningham said:

>
> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
> news:87prp51...@bsb.me.uk...
>
>> [I still think that you should learn an interpreted language.]
>>
> I've come so far with C

No, you haven't. You're still failing to grasp Chapter 1 of K&R2, after
what must be something like a decade of trying. That isn't far. That's
near.

> now why stop ?

Because you're wasting your time.

> Though I have even more to learn.

C is not a large language. I would estimate that you've mastered perhaps a
thousandth of it. In what, ten years? Life's too short. Do something else.

> This C syntax is confusing.

Actually, C's syntax is astoundingly simple. Okay, maybe it takes a little
getting used to - but anyone who is ever going to "get it" will "get it"
within a few weeks or, at most, months.

> Bash and Perl are interesting though.

If you think C's syntax is confusing, you have some real treats in store.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

Kaz Kylheku

unread,
Jul 23, 2008, 6:03:25 PM7/23/08
to
On 2008-07-22, Ben Bacarisse <ben.u...@bsb.me.uk> wrote:
> "Bill Cunningham" <nos...@nspam.com> writes:
>> for (b=0;b<10;b++) {
>>
>> a[ b=b+1];
>> }

[ snip ]

> [I still think that you should learn an interpreted language.]

In light of that cute a[b=b+1] above, it better be one
that is very liberally interpreted, to the point of being
downright charitable. :)

Bill Cunningham

unread,
Jul 23, 2008, 6:29:06 PM7/23/08
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:xrmdnXKS8bTFNBrV...@bt.com...

> Bill Cunningham said:
>
>>
>> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
>> news:87prp51...@bsb.me.uk...
>>
>>> [I still think that you should learn an interpreted language.]
>>>
>> I've come so far with C
>
> No, you haven't. You're still failing to grasp Chapter 1 of K&R2, after
> what must be something like a decade of trying. That isn't far. That's
> near.
[snip]

About 5 years is more like it. And for one year I gave up on C. But
everything is in C or C++. Looking at Bash it doesn't look any simpler
really and in just looks C like. I need someone to explain things to me when
I get stuck. If I had a tutor you would be suprised in what I can pick up.
But that's one thing you don't get in clc. The one thing I need.

Bill


Keith Thompson

unread,
Jul 23, 2008, 6:41:22 PM7/23/08
to

No, I'm afraid you haven't come very far at all with C.

You might consider studying Python. Perl is largely a mish-mash of C,
AWK, shell scripting, and a few other languages. Python has a more
coherent design. Personally, I'm a big fan of Perl, but I don't think
it's the language for you.

Bill Cunningham

unread,
Jul 23, 2008, 6:53:26 PM7/23/08
to

"Keith Thompson" <ks...@mib.org> wrote in message
news:lnd4l4u...@nuthaus.mib.org...

> "Bill Cunningham" <nos...@nspam.com> writes:
>> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
>> news:87prp51...@bsb.me.uk...
>>
>>> [I still think that you should learn an interpreted language.]
>>>
>> I've come so far with C now why stop ? Though I have even more to
>> learn.
>> This C syntax is confusing. Bash and Perl are interesting though.
>
> No, I'm afraid you haven't come very far at all with C.
>
> You might consider studying Python. Perl is largely a mish-mash of C,
> AWK, shell scripting, and a few other languages. Python has a more
> coherent design. Personally, I'm a big fan of Perl, but I don't think
> it's the language for you.
>
There's always assembly :-)

Bill


Ben Bacarisse

unread,
Jul 23, 2008, 6:55:15 PM7/23/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
> news:87prp51...@bsb.me.uk...
>
>> [I still think that you should learn an interpreted language.]
>>
> I've come so far with C now why stop ?

Learning is not like rolling a boulder up a hill. The learning does
not start to pour out of you head the moment you stop stuffing more
in. In fact, you may find that *more* of the C you've seen so far
"sticks" if you take a break and look at something else. The only
reason to keep going would be if you are very close to achieving some
goal with C, but that does not seem to the case.

However, the main reason is because I think you will get on better
with language that allows you to get immediate feedback from trying
things out. I don't say this without some experience of how people
learn programming. Some people are born planners -- they think, plan,
sketch things out, revise the plan, and then write an almost perfect
program first time. Other like to try this construct, have a go with
that idea, wonder why such-and-such behaves like so-and-so and, over
time, they can evolve a program. People in the first group would
prefer to read (often cover to cover) a reference type of book for the
language they are about to use. Those in the second like tutorials
with lost of examples and variations on a theme. I think you are
closer to the second group than the first.

You can learn any language using either style, but interpreted
languages suit the second group better, at least at first.

> Though I have even more to learn.
> This C syntax is confusing. Bash and Perl are interesting though.

Both are a Very Bad Idea (for reasons too messy and off topic to get
into here). I think you would prefer a language where the pieces fit
together in a logical and relatively unconstrained way. The best
example of that is Haskell, but all the best books are rather
expensive (and all the on-line tutorials seem to delight in too much
jargon). My top choice for you would be Scheme because it is clean
and logical and has excellent supporting texts, now entirely free on
the web. See http://mitpress.mit.edu/sicp/ If that is too far removed
from what you know, try Python.

BTW, far more significant would be to find a friend, nearby, who could
help you learn.

--
Ben.

Bill Cunningham

unread,
Jul 23, 2008, 7:17:51 PM7/23/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87k5fcb...@bsb.me.uk...

> "Bill Cunningham" <nos...@nspam.com> writes:
>
>> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
>> news:87prp51...@bsb.me.uk...
>>
>>> [I still think that you should learn an interpreted language.]
>>>
>> I've come so far with C now why stop ?
>
> Learning is not like rolling a boulder up a hill. The learning does
> not start to pour out of you head the moment you stop stuffing more
> in. In fact, you may find that *more* of the C you've seen so far
> "sticks" if you take a break and look at something else. The only
> reason to keep going would be if you are very close to achieving some
> goal with C, but that does not seem to the case.

[snip]

Goal? Read and understand file sections,headers, symbols and sectors. That
would probably involve hex dumps, debuggers, BFD knowledge and logic
understanding to take apart a program to bits and reconstruct whatever I
want like a new file format. That is the goal in my head. But one has to
learn a language with this and assembler will be involved.

Bill


Ben Bacarisse

unread,
Jul 23, 2008, 7:35:56 PM7/23/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
> news:87k5fcb...@bsb.me.uk...
>> "Bill Cunningham" <nos...@nspam.com> writes:
>>
>>> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
>>> news:87prp51...@bsb.me.uk...
>>>
>>>> [I still think that you should learn an interpreted language.]
>>>>
>>> I've come so far with C now why stop ?
>>
>> Learning is not like rolling a boulder up a hill. The learning does
>> not start to pour out of you head the moment you stop stuffing more
>> in. In fact, you may find that *more* of the C you've seen so far
>> "sticks" if you take a break and look at something else. The only
>> reason to keep going would be if you are very close to achieving some
>> goal with C, but that does not seem to the case.
>
> [snip]
>
> Goal? Read and understand file sections,headers, symbols and sectors. That
> would probably involve hex dumps, debuggers, BFD knowledge and logic
> understanding to take apart a program to bits and reconstruct whatever I
> want like a new file format. That is the goal in my head.

I did not say you did not have one. I said, keep up with C if you are
close to achieving a particular goal using it. I don't think you
are. I.e. I don't think you will loose anything by trying a new way
to learn programming.

Your reply reads, to me, as if I have annoyed you. I am sorry if that
is that case, but I accept that it is almost impossible to avoid being
annoying in this medium. My suggestions about how you might change
tack were intended to be helpful. When the path to the summit is too
steep, going sideways can get you up there faster.

> But one has to
> learn a language with this and assembler will be involved.

Very few of these goals (things to learn about) are language specific
and although learning C might help, it seems to me neither necessary
nor sufficient for achieving them.

--
Ben.

Message has been deleted

Bill Cunningham

unread,
Jul 23, 2008, 8:13:11 PM7/23/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87fxq0b...@bsb.me.uk...

Annoyed? Well I do read this as if you are trying to help. But giving up
C is like giving up on math because you have trouble pulling products from
multiples from your head because you have trouble with multiplication. There
are calculators and you can go onto higher maths if you have a little help
with a calculator.

It's like giving up.

Bill


Message has been deleted

Bill Cunningham

unread,
Jul 23, 2008, 8:56:00 PM7/23/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87fxq0b...@bsb.me.uk...

[snipped much]

> Very few of these goals (things to learn about) are language specific
> and although learning C might help, it seems to me neither necessary
> nor sufficient for achieving them.
>

What about taking something like an API like system calls, Glib, GTK+ or
something that is built in C and learn more and more about standard C.

I think that would either help or blow up in my face and confuse me
more.

Bill


Nick Keighley

unread,
Jul 24, 2008, 5:13:14 AM7/24/08
to
On 23 Jul, 03:19, "Bill Cunningham" <nos...@nspam.com> wrote:
> "Keith Thompson" <ks...@mib.org> wrote in message
>
> news:lnr69li...@nuthaus.mib.org...

don't snip so much. You originally said you wanted to:

"take every element of the array a and set it to 1,2,3,4,5"

where "a" was declared int a[5]

> > You don't even understand what a 2 dimensional array is.  Your
> > question assumes that it's a 5-element array followed by a 3-element
> > array.  It isn't.  It's a 5-element array, each of whose elements is a
> > 3-element array of ints, for a total of 15 (5*3) ints.
>
>     I understand if I am correct that each of the 5 elements have 3
> elements. Yes. What I didn't understand was
>
>     a[i]=i+1;

that does what you wanted. I can't imagine how you can *not*
understand it!
I'm beginning to wonder if you have a completely wrong idea how
procedural
languages like C work. You don't appear to understand that the order
of
statements matters or how assignment works.

Consider


for (i = 0; i < 5; i++)

a[i] = i + 1;

Now consider a simple assembler

store i 0 # store zero in i
load r1 i # load register 1 with contents of i
CMP: cmp r1 5 # campare i with 5
jge FI # exit it i >= 5
load r2 r1
inc r2 # r2 = i + 1
load r3 &a
add r3 r1 # r3 = &a[i]
store r3 r2 # store i + 1 in a[i]
inc r1
store i r1 # update i
jmp CMP
FI: nop

A basic compiler would optimise a lot of this away.

--
Nick Keighley

Server rooms should be unfriendly! They should look dangerous,
they should be uncomfortably cold, they should be inexplicably noisy.
If you can arrange for the smell of burning transistors, that's good
too.
If anything, I'd rather see rackmounted servers designed in dark
foreboding
colors with lots of metal spikes sticking out of them.
Mike Sphar (on news//alt.sysadmin.recovery)

Bill Cunningham

unread,
Jul 24, 2008, 3:59:49 PM7/24/08
to

"Mark L Pappin" <m...@acm.org> wrote in message
news:87bq0od...@Don-John.Messina...

[snip]

> 1. Copy and paste this code (between "/*begin1*/" and "/*end1*/") into
> a new source file, compile, and run it. What output does it produce?
>
> /*begin1*/
> #include <stdio.h>
> int main(void){
> /* you are not expected to understand this - it is to
> verify that you can and will follow instructions */
> printf("%s%c%d\n",
> "protest"+3,
> "blank space"[5],
> 27/3-2*2*2);
> return 0;
> }
> /*end1*/
>
>
> 2. Write a program to print a single line containing the greeting
> "Hello, world!" followed by a newline character.

The results I got from your first program was a warning concerning no
newline character and the text

test 1

Here is the answer to #2 of your question.

#include <stdio.h>

int main(void) {
printf("hello world\n");
return 0;
}

Do you wish to correspond through private email ? I will post the answer to
your third question later.

Bill


Bill Cunningham

unread,
Jul 24, 2008, 4:02:43 PM7/24/08
to

"Bill Cunningham" <nos...@nspam.com> wrote in message
news:Va5ik.507$_l.500@trnddc04...

[snip]

> The results I got from your first program was a warning concerning no
> newline character and the text
>
> test 1
>
> Here is the answer to #2 of your question.
>
> #include <stdio.h>
>
> int main(void) {
> printf("hello world\n");
> return 0;
> }

Oops. I forgot the ! at the end of the hello world.
#include <stdio.h>
>
> int main(void) {
> printf("hello world!\n");
> return 0;
> }

There.

Bill

Message has been deleted

Richard

unread,
Jul 24, 2008, 8:37:31 PM7/24/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> I understand this code.
>


> int a[5];
> int b;
> for (b=0;b<5;b=b+1)
> int a[b];
>

> This should take every element of the array a and set it to 1,2,3,4,5.
> Great. Now for the big question. How would you work this?
>
> int a [5][3];
>
> And make the first element of 5 all zeros and the second element of 3 equal

> to 1,2,3 ? I don't know how to work with a 2 dimensional array.
>

> Bill
>
>

Bill, instead of making such elementary mistakes time after time after
time why not just take my advice and step through your code with a
debugger for your system?

Surely you are trolling? You can surely not be so confused at this
stage?

Barry Schwarz

unread,
Jul 24, 2008, 10:08:51 PM7/24/08
to
On Thu, 24 Jul 2008 00:56:00 GMT, "Bill Cunningham" <nos...@nspam.com>
wrote:

>


>"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
>news:87fxq0b...@bsb.me.uk...
>
>[snipped much]
>
>> Very few of these goals (things to learn about) are language specific
>> and although learning C might help, it seems to me neither necessary
>> nor sufficient for achieving them.
>>
> What about taking something like an API like system calls, Glib, GTK+ or
>something that is built in C and learn more and more about standard C.

Don't even think about. You have been on chapter 1 for five years.

>
> I think that would either help or blow up in my face and confuse me
>more.

Until you have firm foundation in basic C, these add-ons will only
serve to confuse you even more than you are now.


Remove del for email

cooldude

unread,
Jul 25, 2008, 2:56:12 AM7/25/08
to
On Jul 23, 3:15 am, "Bill Cunningham" <nos...@nspam.com> wrote:
> I understand this code.
>
> int a[5];
> int b;
> for (b=0;b<5;b=b+1)
> int a[b];
>
>     This should take every element of the array a and set it to 1,2,3,4,5.
> Great. Now for the big question. How would you work this?
>
> int a [5][3];
>
> And make the first element of 5 all zeros and the second element of 3 equal
> to 1,2,3 ? I don't know how to work with a 2 dimensional array.
>
> Bill

hi,
i guess this is wat you want to do ..

for(i=0;i<5;i++)
for(j=0;j<3;j++)
a[i][j]=j;

ur 2D array has 5 rows 3 columns ( 5 x 2 ) 1st column is set to 0 2nd
to 1 3rd to 2 for each row..

lovecreatesbea...@gmail.com

unread,
Jul 25, 2008, 4:41:02 AM7/25/08
to
On Jul 24, 6:41 am, Keith Thompson <ks...@mib.org> wrote:
> "Bill Cunningham" <nos...@nspam.com> writes:
> > "Ben Bacarisse" <ben.use...@bsb.me.uk> wrote in message

> >news:87prp51...@bsb.me.uk...
>
> >> [I still think that you should learn an interpreted language.]
>
> > I've come so far with C now why stop ? Though I have even more to learn.
> > This C syntax is confusing. Bash and Perl are interesting though.
>
> You might consider studying Python. Perl is largely a mish-mash of C,
> AWK, shell scripting, and a few other languages. Python has a more
> coherent design.

I think these are what I need to learn: C (C++ sometimes), Bourne
Shell, Makefile Scripting.

> Personally, I'm a big fan of Perl, but I don't think
> it's the language for you.

Last month, I wrote an automatic ssh and telnet script in Perl.
Because the files for rsh login on the destinate host may not be
available, I need to go to Perl and except. After I code an ssh and
telnet client in C, I can do the job without Perl. Perl is a mess.

Eric Steven Raymond said in his book: ``C and Python are semi-compact;
Perl, Java, Emacs Lisp, and shell are not.'' (http://www.faqs.org/docs/
artu/ch04s02.html#orthogonality)

Ben Bacarisse

unread,
Jul 26, 2008, 3:19:54 PM7/26/08
to
Mark L Pappin <m...@acm.org> writes:

> "Bill Cunningham" <nos...@nspam.com> writes:
>> I will post the answer to your third question later.
>

> I look forward to it

Bill, if it helps, this is thread you should be posting in. (I posted
this just to bump the thread).

--
Ben.

Bill Cunningham

unread,
Jul 27, 2008, 4:38:48 PM7/27/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87myk47...@bsb.me.uk...
Mark,

I don't know how to do this with spaces or for. So I will post another way
of doing it and I don't know how to include spaces. But the program works.

Bill

#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
printf("%s\n",a);
}

Bill


Richard

unread,
Jul 27, 2008, 4:50:03 PM7/27/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
> news:87myk47...@bsb.me.uk...
>> Mark L Pappin <m...@acm.org> writes:
>>
>>> "Bill Cunningham" <nos...@nspam.com> writes:
>>>> I will post the answer to your third question later.
>>>
>>> I look forward to it
>>
>> Bill, if it helps, this is thread you should be posting in. (I posted
>> this just to bump the thread).
>>
> Mark,
>
> I don't know how to do this with spaces or for. So I will post another way
> of doing it and I don't know how to include spaces. But the program
> works.

You don't know how to include spaces?

ROTFLM. It just gets better.

>
> Bill
>
> #include <stdio.h>
>
> int main (void) {
> char a[]={'0','1','2','3','4','5','6'};
> printf("%s\n",a);
> }
>
> Bill

Maybe you could describe, in words, what you are doing there? Did you
bother your arse to look at the data structures in a debugger yet as
advised?

Bill Cunningham

unread,
Jul 27, 2008, 4:55:38 PM7/27/08
to

"Richard" <rgr...@gmail.com> wrote in message
news:g6in1s$j8j$1...@registered.motzarella.org...

All I get from that thing is 'no stack'

Bill


Richard

unread,
Jul 27, 2008, 4:59:10 PM7/27/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

And of course you did not bother to follow the small tutorial that I
pointed you to? You're a waste of time. Actually you're not. You're a
super duper troll!

Ben Bacarisse

unread,
Jul 27, 2008, 5:09:32 PM7/27/08
to
[I am re-posting my reply in case than means everything can be kept in
the one place.]

"Bill Cunningham" <nos...@nspam.com> writes:

> "Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
> news:87myk47...@bsb.me.uk...
>> Mark L Pappin <m...@acm.org> writes:
>>
>>> "Bill Cunningham" <nos...@nspam.com> writes:
>>>> I will post the answer to your third question later.
>>>
>>> I look forward to it
>>
>> Bill, if it helps, this is thread you should be posting in. (I posted
>> this just to bump the thread).

<snip>


> I don't know how to do this with spaces or for. So I will post another way
> of doing it and I don't know how to include spaces. But the program
> works.

You were unlucky. I have more luck, it seems. On my system I get:

0123456�-��H.��Pt���l��ЃH.��Pt��

Do you know why?

> #include <stdio.h>
>
> int main (void) {
> char a[]={'0','1','2','3','4','5','6'};

I am surprised that:

char a[]={'0',' ','1',' ','2',' ','3',' ','4',' ','5',' ','6'};

did not occur to you. Knowing why you did not think of it is probably
more helpful than getting the program right. For example, did you
look for, and not find, a special escape sequence for a space
character (like there is for newline: '\n'). If so what did you do
when you did not find it? Maybe you simply did not know how to write
a space and you don't know any way to find such things out. I have a
feeling that examining these questions will be more helpful to you
than someone telling you how to write a space.

> printf("%s\n",a);
> }

--
Ben.

Bill Cunningham

unread,
Jul 27, 2008, 5:14:57 PM7/27/08
to

"Richard" <rgr...@gmail.com> wrote in message
news:g6iniv$j8j$3...@registered.motzarella.org...

> And of course you did not bother to follow the small tutorial that I
> pointed you to? You're a waste of time. Actually you're not. You're a
> super duper troll!

Actually I bookmarked the tutorial and haven't got a chance to really
read over it. I have been writing several C utilities and they have been
working so when I pop them into gdb and try to run them they end without an
error code.

Bill


Bill Cunningham

unread,
Jul 27, 2008, 5:17:46 PM7/27/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87zlo33...@bsb.me.uk...

> You were unlucky. I have more luck, it seems. On my system I get:
>

> 0123456?-??H.??Pt???l???H.??Pt??
>
> Do you know why?

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

Bill


Ben Bacarisse

unread,
Jul 27, 2008, 5:20:51 PM7/27/08
to
Richard<rgr...@gmail.com> writes:

<snip program>


> You don't know how to include spaces?
>
> ROTFLM. It just gets better.

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.

>> #include <stdio.h>
>>
>> int main (void) {
>> char a[]={'0','1','2','3','4','5','6'};
>> printf("%s\n",a);
>> }
>>
>> Bill
>
> Maybe you could describe, in words, what you are doing there? Did you
> bother your arse to look at the data structures in a debugger yet as
> advised?

He said it worked so presumably if he'd looked he'd see what he expects
to see. For example, in gdb it shows:

(gdb) print a
$1 = "0123456"
(gdb) print a[6]
$2 = 54 '6'
(gdb) print a[7]
$3 = 0 '\0'

You have to know what's wrong to ask the right question:

(gdb) print sizeof a
$4 = 7

This is one problem with using a debugger to learn with -- it shows
you only what happens not what your code means.

--
Ben.

Richard

unread,
Jul 27, 2008, 5:24:39 PM7/27/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

Stop writing C utilities until you figure out strings. Trust me. use the
debugger to inspect your data structures.


Richard

unread,
Jul 27, 2008, 5:27:25 PM7/27/08
to
Ben Bacarisse <ben.u...@bsb.me.uk> writes:

> Richard<rgr...@gmail.com> writes:
>
> <snip program>
>> You don't know how to include spaces?
>>
>> ROTFLM. It just gets better.
>
> 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.

I can not make up my mind. I have given him lots of good advice. Until
he tries to follow some then I think a good laugh is in order...

>
>>> #include <stdio.h>
>>>
>>> int main (void) {
>>> char a[]={'0','1','2','3','4','5','6'};
>>> printf("%s\n",a);
>>> }
>>>
>>> Bill
>>
>> Maybe you could describe, in words, what you are doing there? Did you
>> bother your arse to look at the data structures in a debugger yet as
>> advised?
>
> He said it worked so presumably if he'd looked he'd see what he expects
> to see. For example, in gdb it shows:

Why are you telling me what it looks like? I know what it looks like. He
needs to know what it looks like. The thing you have to remember with
Bill is that he heasn't a clue what "works" means since half the time he
doesnt appear to know what it is he wants to work.

It is up to HIM to use the tools. Not for others to tell him what the
tools will tell him.

>
> (gdb) print a
> $1 = "0123456"
> (gdb) print a[6]
> $2 = 54 '6'
> (gdb) print a[7]
> $3 = 0 '\0'
>
> You have to know what's wrong to ask the right question:
>
> (gdb) print sizeof a
> $4 = 7
>
> This is one problem with using a debugger to learn with -- it shows
> you only what happens not what your code means.

To see the data is a major part of understanding that the code has
done. If he is serious that he doesn't know how to put spaces in then he
says some serious basic issues. And a debugger can show, down and dirty,
just what he is dealing with.

Bill Cunningham

unread,
Jul 27, 2008, 5:51:43 PM7/27/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
news:87vdyr3...@bsb.me.uk...

> He said it worked so presumably if he'd looked he'd see what he expects
> to see. For example, in gdb it shows:
>
> (gdb) print a
> $1 = "0123456"
> (gdb) print a[6]
> $2 = 54 '6'
> (gdb) print a[7]
> $3 = 0 '\0'
>
> You have to know what's wrong to ask the right question:
>
> (gdb) print sizeof a
> $4 = 7
>
> This is one problem with using a debugger to learn with -- it shows
> you only what happens not what your code means.

...And you are your best debugger. I guess I am in that camp. However,
if Richard is talking about file sectors and segments and the internals of
files like symbol tables and headers I might just be interested in learning
a little more about gdb.

Bill


Richard

unread,
Jul 27, 2008, 6:09:55 PM7/27/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

LOL. Yeah Bill. That's what I'm talking about. Hint : I am not. I am
talking about bog standard strings or character arrays.

Go away. Read the tutorial and LEARN how to do things yourself for a
while. And stop moving on to things you are clearly clueless about until
you understand the basics of examining data and, at the very least, the
C string "type".

Ben Bacarisse

unread,
Jul 27, 2008, 6:17:24 PM7/27/08
to
Richard<rgr...@gmail.com> writes:

> Ben Bacarisse <ben.u...@bsb.me.uk> writes:
>
>> Richard<rgr...@gmail.com> writes:
>>
>> <snip program>
>>> You don't know how to include spaces?
>>>
>>> ROTFLM. It just gets better.
>>
>> 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.
>
> I can not make up my mind. I have given him lots of good advice. Until
> he tries to follow some then I think a good laugh is in order...

That is up to up.

<snip>


>> He said it worked so presumably if he'd looked he'd see what he expects
>> to see. For example, in gdb it shows:
>
> Why are you telling me what it looks like?

Because you seem to think it might help. I wanted to show that you are
wrong in this case.

> I know what it looks like. He
> needs to know what it looks like. The thing you have to remember with
> Bill is that he heasn't a clue what "works" means since half the time he
> doesnt appear to know what it is he wants to work.

The debugger will show the same as the execution run which he says
worked. Only a cleverer C debugger than I have yet used will show him
that anything is wrong (if he continues to be unlucky in his data's
layout).

> It is up to HIM to use the tools. Not for others to tell him what the
> tools will tell him.

It will not help to suggest a tool that can't help in this case.

>> (gdb) print a
>> $1 = "0123456"
>> (gdb) print a[6]
>> $2 = 54 '6'
>> (gdb) print a[7]
>> $3 = 0 '\0'
>>
>> You have to know what's wrong to ask the right question:
>>
>> (gdb) print sizeof a
>> $4 = 7
>>
>> This is one problem with using a debugger to learn with -- it shows
>> you only what happens not what your code means.
>
> To see the data is a major part of understanding that the code has
> done. If he is serious that he doesn't know how to put spaces in then he
> says some serious basic issues. And a debugger can show, down and dirty,
> just what he is dealing with.

Which is of course correct (because he was unlucky) so the debugger
can do little but show him that all is as he thought it should be.

--
Ben.

Default User

unread,
Jul 27, 2008, 6:59:47 PM7/27/08
to
Ben Bacarisse wrote:

> Richard<rgr...@gmail.com> writes:
>
> <snip program>
> > You don't know how to include spaces?
> >
> > ROTFLM. It just gets better.
>
> 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.

Riley is a troll. We've been over this.


Brian

Richard

unread,
Jul 27, 2008, 7:02:49 PM7/27/08
to
Ben Bacarisse <ben.u...@bsb.me.uk> writes:

> Richard<rgr...@gmail.com> writes:
>
>> Ben Bacarisse <ben.u...@bsb.me.uk> writes:
>>
>>> Richard<rgr...@gmail.com> writes:
>>>
>>> <snip program>
>>>> You don't know how to include spaces?
>>>>
>>>> ROTFLM. It just gets better.
>>>
>>> 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.
>>
>> I can not make up my mind. I have given him lots of good advice. Until
>> he tries to follow some then I think a good laugh is in order...
>
> That is up to up.
>
> <snip>
>>> He said it worked so presumably if he'd looked he'd see what he expects
>>> to see. For example, in gdb it shows:
>>
>> Why are you telling me what it looks like?
>
> Because you seem to think it might help. I wanted to show that you are
> wrong in this case.

No. I am not wrong in this case. It is always more than the issue at
hand.

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.

Richard

unread,
Jul 27, 2008, 7:05:24 PM7/27/08
to
"Default User" <defaul...@yahoo.com> writes:

You have your people mixed up. I would like to point out that your
contributions appear to be nothing more than net nannying and
whinging. I am deadly serious with my advice to Bill. Learn to use the
tools to help you understand the basics. It is quite clear he will not
understand stuff from the "standard" for example. All your blathering
and pouting will get him no where. And at least Ben helps and gets stuck
in so a discussion with him on the best approach is not a waste of
time. What do you do? Now, if you have anything positive to contribute,
please do, otherwise go and put your big nose somewhere where it might
be appreciated. Thank you.

Mark L Pappin

unread,
Jul 27, 2008, 7:12:17 PM7/27/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> I don't know how to do this with spaces or for.

OK, it appears that you've not "got it" as I had hoped you might, so
here are the underlying ideas you need to move from "print a thing
that's hard-coded in the source" to "print a sequence of things that
can be computed".

- an 'int' variable can hold values from 0 up to INT_MAX (and down to
INT_MIN, but that's not important right now), where INT_MAX is at
least 32767
- 'printf()' can print the value of an 'int' variable, as well as a
literal string
- a 'for' loop can initialize a variable, loop around "doing stuff"
until that variable hits an upper limit, and increment the variable
after each time it has "done stuff"

(There are other concepts that could be used to implement this, like
'unsigned int', 'if', etc. They are also Not Important Right Now.)


Since you appear to need it, here's a template for you. Replace the
comments with source that does what's suggested.

#include <stdio.h>
int main(void) {

/* define an int variable called i */

for (/* set i to the value 0 */ ;
/* test to see that i is still less than 7 */ ;
/* increment i*/) {

/* print the value of i as a decimal integer */
/* print a space */

}

/* print a newline, since you only need one of them */

return 0;
}


The "a-ha!" moment I'm hoping you'll have here is the realisation that
the program does not need to have _everything_ laid out explicitly for
it, but instead its behaviour can be described at a higher level. For
instance, if question 3 was changed to ask for all the integers from 0
to 100 as output, then your first answer would need to have the string
extended by around 300 characters, but the above program would merely
need the test changed from "is i less than 7?" to "is i less than
101?". In the real world, specifications _do_ change like this, so
having a tool to make handling the change easy is an advantage.


> So I will post another way of doing it and I don't know how to
> include spaces. But the program works.

It only "works" because you were unlucky. Ben has given you an
example of a place where it doesn't "work", but you obviously don't
understand why.

> #include <stdio.h>
>
> int main (void) {
> char a[]={'0','1','2','3','4','5','6'};

The line above creates an array of 7 characters only. What sits after
those characters in memory could be anything.

> printf("%s\n",a);

The "%s" format specifier must be given a string.
A string is a sequence of characters ending with a '\0'.
The array whose starting address you have passed is not a string.
The standard does not define what happens now.

In your case there just happened to be a '\0' sitting in the chunk of
memory immediately after 'a[]'; in Ben's there wasn't.


For now, don't think about using array notation until I suggest that
it might be handy for solving a particular problem.


mlp

Ben Bacarisse

unread,
Jul 27, 2008, 8:01:45 PM7/27/08
to
"Default User" <defaul...@yahoo.com> writes:

<snip>
> Riley is a troll.

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.

> We've been over this.

If you mean by this that you've given me your opinion before, then I
take your word for it. If you mean that most people here are of that
opinion, then I agree, and that is in part why I posted. If anyone
else had chosen to point out how a debugger is unlikely to help in
this case, I would not have felt the need.

I have found "Plain Richard" to be someone that I do not want to argue
with. He does not try to understand other people's positions and
will, in the end, resort to claiming that he just does not believe his
opponents. That does not mean, to me, that everything he writes
should go unchallenged. Sometimes I want to offer an opposing view
but you will see that I am quite happy to let him have the last word.
He has explained his position and I have clarified mine.

Of course you (and others) are free to tell me whose posts you think I
should ignore. I take that advice seriously (but not as gospel). For
some reason (which I really don't understand) I don't feel I want to
offer such advice myself.

--
Ben.

Bill Cunningham

unread,
Jul 27, 2008, 9:30:39 PM7/27/08
to

"Mark L Pappin" <m...@acm.org> wrote in message
news:87d4kyy...@Don-John.Messina...
#include <stdio.h>

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

/* This is the code I came up with */

0
1
2
3
4
5
6

Hum. Now I didn't expect that. I expected the numbers to be printed
horizontally.

Bill


Richard

unread,
Jul 27, 2008, 9:46:49 PM7/27/08
to
Ben Bacarisse <ben.u...@bsb.me.uk> writes:

> "Default User" <defaul...@yahoo.com> writes:
>
> <snip>
>> Riley is a troll.
>
> 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.
>
>> We've been over this.
>
> If you mean by this that you've given me your opinion before, then I
> take your word for it. If you mean that most people here are of that

"over this" - he has given his instructions.....

> opinion, then I agree, and that is in part why I posted. If anyone
> else had chosen to point out how a debugger is unlikely to help in
> this case, I would not have felt the need.

The point is that it would. 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 and I have seen people almost as stuck as Bill. 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.

>
> I have found "Plain Richard" to be someone that I do not want to argue
> with. He does not try to understand other people's positions and
> will, in the end, resort to claiming that he just does not believe his
> opponents.

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.

> That does not mean, to me, that everything he writes
> should go unchallenged. Sometimes I want to offer an opposing view
> but you will see that I am quite happy to let him have the last word.
> He has explained his position and I have clarified mine.

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. Pasting in solutions for him is not helping
him - 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.

> Of course you (and others) are free to tell me whose posts you think I
> should ignore. I take that advice seriously (but not as gospel). For
> some reason (which I really don't understand) I don't feel I want to
> offer such advice myself.

Bwian does it a lot. He has been called on it a lot. I have no idea why
he feels the need to tell others who or what to listen to. Frankly I
think he sees himself as Heathfield's right hand man or Rottweiler. I'm
not sure which.

Richard Heathfield

unread,
Jul 27, 2008, 9:52:20 PM7/27/08
to
Bill Cunningham said:

<snip>

> #include <stdio.h>
>
> int main() {
> int i;
> for(i=0;i<7;i++)
> printf("%i \n",i);
> }
>
> /* This is the code I came up with */
>
> 0
> 1
> 2
> 3
> 4
> 5
> 6
>
> Hum. Now I didn't expect that. I expected the numbers to be printed
> horizontally.

Let's look at your printf again:

printf("%i \n",i);

Specifically, let's look at the format string:

"%i \n"

Why did you put the %i there?
Why did you put the space there?
Why did you put the \n there?

What effect do you think the \n will have, each time through the loop?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

Keith Thompson

unread,
Jul 27, 2008, 10:02:18 PM7/27/08
to
"Bill Cunningham" <nos...@nspam.com> writes:
[snip]

Perhaps you and Mark Pappin can agree on a tag for the subject header
of any articles for Mark's attempts to provide you with a tutorial.
I suggest "[BC]".

--
Keith Thompson (The_Other_Keith) ks...@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"

Bill Cunningham

unread,
Jul 27, 2008, 10:59:45 PM7/27/08
to

"Bill Cunningham" <nos...@nspam.com> wrote in message
news:3j9jk.201$Ht4.163@trnddc01...

> 0
> 1
> 2
> 3
> 4
> 5
> 6
>
> Hum. Now I didn't expect that. I expected the numbers to be printed
> horizontally.
>

what am i saying ? Of course they are going to go vertically because of \n

Bill


Bill Cunningham

unread,
Jul 27, 2008, 11:02:15 PM7/27/08
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:Y8ednSBhr-G3uBDV...@bt.com...

> What effect do you think the \n will have, each time through the loop?
>

Sorry Richard. I fogot again.

Bill


Barry Schwarz

unread,
Jul 27, 2008, 11:56:46 PM7/27/08
to
On Sun, 27 Jul 2008 21:51:43 GMT, "Bill Cunningham" <nos...@nspam.com>
wrote:

>
>"Ben Bacarisse" <ben.u...@bsb.me.uk> wrote in message
>news:87vdyr3...@bsb.me.uk...
>> He said it worked so presumably if he'd looked he'd see what he expects
>> to see. For example, in gdb it shows:
>>
>> (gdb) print a
>> $1 = "0123456"
>> (gdb) print a[6]
>> $2 = 54 '6'
>> (gdb) print a[7]
>> $3 = 0 '\0'
>>
>> You have to know what's wrong to ask the right question:
>>
>> (gdb) print sizeof a
>> $4 = 7
>>
>> This is one problem with using a debugger to learn with -- it shows
>> you only what happens not what your code means.
>
> ...And you are your best debugger. I guess I am in that camp. However,

Not only are you not in that camp, you may not even be on the same
planet.

>if Richard is talking about file sectors and segments and the internals of
>files like symbol tables and headers I might just be interested in learning
>a little more about gdb.

Are you sure this shouldn't be a while loop to match your last
haphazard guess? If you are going to throw terms around at random,
don't you want to stick to C terms?


Remove del for email

Barry Schwarz

unread,
Jul 27, 2008, 11:56:46 PM7/27/08
to
On Sun, 27 Jul 2008 21:14:57 GMT, "Bill Cunningham" <nos...@nspam.com>
wrote:

>

Given your monumental lack of understanding of the most fundamental C
concepts as exhibited by the code you have posted and the excuses you
hide behind, how can you possibly even think of writing a utility, let
alone claim that it works?


Remove del for email

Mark L Pappin

unread,
Jul 27, 2008, 11:57:03 PM7/27/08
to
Keith Thompson <ks...@mib.org> writes:

> "Bill Cunningham" <nos...@nspam.com> writes:
> [snip]
>
> Perhaps you and Mark Pappin can agree on a tag for the subject header
> of any articles for Mark's attempts to provide you with a tutorial.
> I suggest "[BC]".

That sounds like a reasonable idea, Keith.

Bill, to eliminate the potential problem of your news server expiring
the most recent posting in this thread before you've replied, and to
eliminate the actual problem of the Subject line not reflecting the
content of the posts, please add "[BC]" to the subject line of any new
thread you start that relates to our ongoing exhibition tutorial.
You'll notice that I've updated the Subject here.

Richard Heathfield <r...@see.sig.invalid> writes:

> Bill Cunningham said:
>
> <snip>
>
>> #include <stdio.h>
>>
>> int main() {
>> int i;
>> for(i=0;i<7;i++)
>> printf("%i \n",i);
>> }

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.


>> Hum. Now I didn't expect that. I expected the numbers to be printed
>> horizontally.

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

Default User

unread,
Jul 28, 2008, 12:39:14 AM7/28/08
to
Ben Bacarisse wrote:

> "Default User" <defaul...@yahoo.com> writes:
>
> <snip>
> > Riley is a troll.
>
> 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.

You're free to feel that way. Actions speak louder than words. Riley,
along with Kenny and Twink, have the goal to disrupt the forum.


Brian

Richard

unread,
Jul 28, 2008, 12:58:21 AM7/28/08
to
"Default User" <defaul...@yahoo.com> writes:

Which part of my sage advice to get a beginner like Bill familiar with C
data structure do you disagree with Bwian?

Tell me, do you ever offer any opinion of your own which is not directly
linked to petty net nannying? Every group has one - and you're the c.l.c
one. Well done.

Chris Torek

unread,
Jul 28, 2008, 5:31:00 AM7/28/08
to
I apologize in advance for yet another off-topic posting, but it
may explain a lot of things (if my assumptions are correct).

In article <87d4kyy...@Don-John.Messina>
Mark L Pappin <m...@acm.org> wrote, in reply to Bill Cunningham:
>The "a-ha!" moment I'm hoping you'll [i.e., Bill will] have here ...

He may well have it, but then I suspect he will need to have it
again the next day.

At one point, Mr Cunnigham mentioned that he was on Klonopin (a
brand name for clonazepam). I suspect (given the evidence accumulated
over several years) that he still is, and has been on it for a very
long time. This particular drug has a nasty side effect: it often
causes a sort of anterograde amnesia, making it impossible to learn
new things. (Depending on the degree of effect, some new things
might be learned over time, but not much, and not quickly.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html

Richard

unread,
Jul 28, 2008, 7:18:24 AM7/28/08
to
Chris Torek <nos...@torek.net> writes:

> I apologize in advance for yet another off-topic posting, but it
> may explain a lot of things (if my assumptions are correct).
>
> In article <87d4kyy...@Don-John.Messina>
> Mark L Pappin <m...@acm.org> wrote, in reply to Bill Cunningham:
>>The "a-ha!" moment I'm hoping you'll [i.e., Bill will] have here ...
>
> He may well have it, but then I suspect he will need to have it
> again the next day.
>
> At one point, Mr Cunnigham mentioned that he was on Klonopin (a
> brand name for clonazepam). I suspect (given the evidence accumulated
> over several years) that he still is, and has been on it for a very
> long time. This particular drug has a nasty side effect: it often
> causes a sort of anterograde amnesia, making it impossible to learn
> new things. (Depending on the degree of effect, some new things
> might be learned over time, but not much, and not quickly.)

In that case he is fighting a losing battle learning C as he is. He
would be far better off following a measured tutorial and reviewing the
lessons daily. Random questions to a usenet group will do him no good
whatsoever.

Nick Keighley

unread,
Jul 28, 2008, 8:39:33 AM7/28/08
to
On 28 Jul, 02:46, Richard<rgr...@gmail.com> wrote:
> Ben Bacarisse <ben.use...@bsb.me.uk> writes:
> > "Default User" <defaultuse...@yahoo.com> writes:

> >> Riley is a troll.

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

<snip>

> > opinion, then I agree, and that is in part why I posted.  If anyone
> > else had chosen to point out how a debugger is unlikely to help in
> > this case, I would not have felt the need.
>
> 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

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)

Nick Keighley

unread,
Jul 28, 2008, 8:46:55 AM7/28/08
to
On 27 Jul, 22:17, "Bill Cunningham" <nos...@nspam.com> wrote:
> "Ben Bacarisse" <ben.use...@bsb.me.uk> wrote in message
> news:87zlo33...@bsb.me.uk...

> > You were unlucky.  I have more luck, it seems.  On my system I get:
>
> > 0123456?-??H.??Pt???l???H.??Pt??
>
> > Do you know why?
>
> 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.


--
Nick Keighley

Richard

unread,
Jul 28, 2008, 8:52:24 AM7/28/08
to
Nick Keighley <nick_keigh...@hotmail.com> writes:

> On 28 Jul, 02:46, Richard<rgr...@gmail.com> wrote:
>> Ben Bacarisse <ben.use...@bsb.me.uk> writes:
>> > "Default User" <defaultuse...@yahoo.com> writes:
>
>> >> Riley is a troll.
>
> propably not. I'm sure he sincerly believes he's right
>
> <snip>
>
>> > opinion, then I agree, and that is in part why I posted.  If anyone
>> > else had chosen to point out how a debugger is unlikely to help in
>> > this case, I would not have felt the need.
>>
>> The point is that it would.
>
> 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.


Richard

unread,
Jul 28, 2008, 8:56:45 AM7/28/08
to
Nick Keighley <nick_keigh...@hotmail.com> writes:

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.

Richard Heathfield

unread,
Jul 28, 2008, 1:19:38 PM7/28/08
to
Nick Keighley said:

> On 28 Jul, 02:46, Richard<rgr...@gmail.com> wrote:
>> Ben Bacarisse <ben.use...@bsb.me.uk> writes:
>> > "Default User" <defaultuse...@yahoo.com> writes:
>
>> >> Riley is a troll.
>
> propably not. I'm sure he sincerly believes he's right

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>

Default User

unread,
Jul 28, 2008, 2:24:00 PM7/28/08
to
Nick Keighley wrote:

> On 28 Jul, 02:46, Richard<rgr...@gmail.com> wrote:
> > Ben Bacarisse <ben.use...@bsb.me.uk> writes:
> > > "Default User" <defaultuse...@yahoo.com> writes:
>
> > >> Riley is a troll.
>
> 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

Richard

unread,
Jul 28, 2008, 2:28:35 PM7/28/08
to
"Default User" <defaul...@yahoo.com> writes:

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.

Ben Bacarisse

unread,
Jul 28, 2008, 2:29:12 PM7/28/08
to
Richard<rgr...@gmail.com> writes:

> Nick Keighley <nick_keigh...@hotmail.com> writes:
>
>> On 27 Jul, 22:17, "Bill Cunningham" <nos...@nspam.com> wrote:
>>> "Ben Bacarisse" <ben.use...@bsb.me.uk> wrote in message
>>> news:87zlo33...@bsb.me.uk...
>>
>>> > You were unlucky.  I have more luck, it seems.  On my system I get:
>>>
>>> > 0123456?-??H.??Pt???l???H.??Pt??
>>>
>>> > Do you know why?
>>>
>>> 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.
>
> 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.

--
Ben.

Richard

unread,
Jul 28, 2008, 2:31:27 PM7/28/08
to
Richard Heathfield <r...@see.sig.invalid> writes:

> Nick Keighley said:
>
>> On 28 Jul, 02:46, Richard<rgr...@gmail.com> wrote:
>>> Ben Bacarisse <ben.use...@bsb.me.uk> writes:
>>> > "Default User" <defaultuse...@yahoo.com> writes:
>>
>>> >> Riley is a troll.
>>
>> propably not. I'm sure he sincerly believes he's right
>
> 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.

Richard

unread,
Jul 28, 2008, 2:34:43 PM7/28/08
to
Ben Bacarisse <ben.u...@bsb.me.uk> writes:

> Richard<rgr...@gmail.com> writes:
>
>> Nick Keighley <nick_keigh...@hotmail.com> writes:
>>
>>> On 27 Jul, 22:17, "Bill Cunningham" <nos...@nspam.com> wrote:
>>>> "Ben Bacarisse" <ben.use...@bsb.me.uk> wrote in message
>>>> news:87zlo33...@bsb.me.uk...
>>>
>>>> > You were unlucky.  I have more luck, it seems.  On my system I get:
>>>>
>>>> > 0123456?-??H.??Pt???l???H.??Pt??
>>>>
>>>> > Do you know why?
>>>>
>>>> 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.
>>
>> Maybe even get a debugger to show the "string" a?
>
> 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.

Keith Thompson

unread,
Jul 28, 2008, 2:58:27 PM7/28/08
to
Richard<rgr...@gmail.com> writes:
> Richard Heathfield <r...@see.sig.invalid> writes:
>> Nick Keighley said:
>>> On 28 Jul, 02:46, Richard<rgr...@gmail.com> wrote:
>>>> Ben Bacarisse <ben.use...@bsb.me.uk> writes:
>>>> > "Default User" <defaultuse...@yahoo.com> writes:
>>>> >> 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.)

Serve Lau

unread,
Jul 28, 2008, 3:08:50 PM7/28/08
to

"Ben Bacarisse" <ben.u...@bsb.me.uk> schreef in bericht
news:87vdyr3...@bsb.me.uk...
> Richard<rgr...@gmail.com> writes:
>
> <snip program>
>> You don't know how to include spaces?
>>
>> ROTFLM. It just gets better.
>
> 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.

Antoninus Twink

unread,
Jul 28, 2008, 4:49:50 PM7/28/08
to
On 28 Jul 2008 at 0:01, Ben Bacarisse wrote:

> "Default User" <defaul...@yahoo.com> writes:
>> Riley is a troll.
>
> 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.

Antoninus Twink

unread,
Jul 28, 2008, 4:52:07 PM7/28/08
to
On 28 Jul 2008 at 18:24, Default User wrote:
> 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"?

Bill Cunningham

unread,
Jul 28, 2008, 5:11:26 PM7/28/08
to

"Mark L Pappin" <m...@acm.org> wrote in message
news:8763qqy8...@Don-John.Messina...

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

Mark L Pappin

unread,
Jul 28, 2008, 7:09:34 PM7/28/08
to
"Bill Cunningham" <nos...@nspam.com> writes:

> "Mark L Pappin" <m...@acm.org> wrote:

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

> 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

Bill Cunningham

unread,
Jul 28, 2008, 8:03:45 PM7/28/08
to

"Mark L Pappin" <m...@acm.org> wrote in message
news:87proxw...@Don-John.Messina...

> 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


santosh

unread,
Jul 28, 2008, 10:51:33 PM7/28/08
to
Richard wrote:

<snip>

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

Chris Thomasson

unread,
Jul 29, 2008, 12:19:52 AM7/29/08
to
"santosh" <santo...@gmail.com> wrote in message
news:g6m0jl$d9q$1...@registered.motzarella.org...

Bill probably works for Microsoft.

Message has been deleted

Keith Thompson

unread,
Jul 29, 2008, 2:56:06 AM7/29/08
to
santosh <santo...@gmail.com> writes:
[...]

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

santosh

unread,
Jul 29, 2008, 5:24:37 AM7/29/08
to
Keith Thompson wrote:
> santosh <santo...@gmail.com> writes:
> [...]
>> 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?

Well, he is obviously using the newsreader 'trn' setup to masquerade as
OE, isn't he?

Keith Thompson

unread,
Jul 29, 2008, 2:16:19 PM7/29/08
to

It wasn't obvious to me; I never bothered to look at the headers.

Bill Cunningham

unread,
Jul 29, 2008, 3:15:00 PM7/29/08
to
Mark,

I do have a program called indent. I can run all my source through that and
have a consistant scheme of code. Otherwise does this look better?

#include <stdio.h>

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

printf("\n");
return 0;
}

I think it's more rreadable. Is this what you suggested?

Bill


Bill Cunningham

unread,
Jul 29, 2008, 3:31:07 PM7/29/08
to
Mark,

Well it took awhile and a lot of guessing and working with printf but I
finally got q3c.

#include <stdio.h>

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

printf("\n");
return 0;
}

How is the indentation on this one ?

Bill


Keith Thompson

unread,
Jul 29, 2008, 4:18:17 PM7/29/08
to

The indentation is mostly ok, but it's inconsistent. You're using 7
columns for the body of your function, but only 2 for the body of your
for loop. I suggest you consult the documentation of indent to find a
set of options that makes the levels consistent. My personal
recommendation is 4 columns for each level.

A comment on your code. Why did you write

"%i" " "

? Do you understand exactly what that syntax means (I'm referring to
the quotation marks, not the %i). Is there a simpler and clearer way
to say exactly the same thing? (Hint: Yes, there is.)

Bill Cunningham

unread,
Jul 29, 2008, 6:49:52 PM7/29/08
to

"Keith Thompson" <ks...@mib.org> wrote in message
news:lnk5f4i...@nuthaus.mib.org...

> A comment on your code. Why did you write
>
> "%i" " "
>
> ? Do you understand exactly what that syntax means (I'm referring to
> the quotation marks, not the %i).

Nope.

Is there a simpler and clearer way
> to say exactly the same thing? (Hint: Yes, there is.)

I had no idea what I was doing. I was hoping I would get it right and
kept fiddling around with printfs' formatting til I got a space in between
each number. My text (not k&r2) said ' ' would be a space. It wasn't. I only
got number like such

'0''1''2'...

Bill

vipp...@gmail.com

unread,
Jul 29, 2008, 8:38:42 PM7/29/08
to
On Jul 29, 9:16 pm, Keith Thompson <ks...@mib.org> wrote:

> santosh<santosh....@gmail.com> writes:
> > Well, he is obviously using the newsreader 'trn' setup to masquerade as
> >OE, isn't he?
>
> It wasn't obvious to me; I never bothered to look at the headers.

Okay but now that it's been pointed out to you by someone, do you
still believe that Cunningham is genuine?

Keith Thompson

unread,
Jul 29, 2008, 8:50:39 PM7/29/08
to

I have no idea. For all I know, there could be perfectly valid
reasons to have trn masquerade (poorly) as OE. (I've done similar
things with web browsers in the past, telling Opera to masquerade as
Internet Explorer.) Or the Message-ID might have been set somewhere
else. Or his X-Newsreader: header might be incorrect. Or something I
haven't thought of.

Why would a troll post with trn masquerading as OE anyway? What would
be the point? Even if there's no innocent explanation, I don't see a
plausible guilty explanation. What do you have in mind?

Bill Cunningham: Do you have any comment on this? Do you know why
your X-Newsreader: header implies you're using Outlook Express, but
your Message-ID implies you're using trn?

vipp...@gmail.com

unread,
Jul 29, 2008, 9:04:26 PM7/29/08
to
On Jul 30, 3:50 am, Keith Thompson <ks...@mib.org> wrote:

> vipps...@gmail.com writes:
> > On Jul 29, 9:16 pm, Keith Thompson <ks...@mib.org> wrote:
> >> santosh<santosh....@gmail.com> writes:
> >> > Well, he is obviously using the newsreader 'trn' setup to masquerade as
> >> >OE, isn't he?
>
> >> It wasn't obvious to me; I never bothered to look at the headers.
>
> > Okay but now that it's been pointed out to you by someone, do you
> > still believe that Cunningham is genuine?
>
> I have no idea. For all I know, there could be perfectly valid
> reasons to have trn masquerade (poorly) as OE. (I've done similar
> things with web browsers in the past, telling Opera to masquerade as
> Internet Explorer.) Or the Message-ID might have been set somewhere
> else. Or his X-Newsreader: header might be incorrect. Or something I
> haven't thought of.
>
> Why would a troll post with trn masquerading as OE anyway? What would
> be the point? Even if there's no innocent explanation, I don't see a
> plausible guilty explanation. What do you have in mind?

I can think of one: so that the troll can have an excuse for
constantly messing with the posts. (ie removing attributes, top-
posting, messing up quotes, stuff that Bill frequently does)
Why he doesn't genuinely use OE instead of "masquerading", I believe
because the troll does not use windows.

Chris Thomasson

unread,
Jul 30, 2008, 1:50:52 AM7/30/08
to

"Bill Cunningham" <nos...@nspam.com> wrote in message
news:k8Njk.515$rb5.272@trnddc04...

>
> "Keith Thompson" <ks...@mib.org> wrote in message
> news:lnk5f4i...@nuthaus.mib.org...
>
>> A comment on your code. Why did you write
>>
>> "%i" " "
>>
>> ? Do you understand exactly what that syntax means (I'm referring to
>> the quotation marks, not the %i).
>
> Nope.

Don't you think that:

"%i "

would be cleaner and easier to read?

santosh

unread,
Jul 30, 2008, 2:00:31 AM7/30/08
to
Keith Thompson wrote:

> vipp...@gmail.com writes:
>> On Jul 29, 9:16 pm, Keith Thompson <ks...@mib.org> wrote:
>>> santosh<santosh....@gmail.com> writes:
>>> > Well, he is obviously using the newsreader 'trn' setup to
>>> > masquerade as
>>> >OE, isn't he?
>>>
>>> It wasn't obvious to me; I never bothered to look at the headers.
>>
>> Okay but now that it's been pointed out to you by someone, do you
>> still believe that Cunningham is genuine?
>
> I have no idea. For all I know, there could be perfectly valid
> reasons to have trn masquerade (poorly) as OE. (I've done similar
> things with web browsers in the past, telling Opera to masquerade as
> Internet Explorer.) Or the Message-ID might have been set somewhere
> else. Or his X-Newsreader: header might be incorrect. Or something I
> haven't thought of.
>
> Why would a troll post with trn masquerading as OE anyway? What would
> be the point? Even if there's no innocent explanation, I don't see a
> plausible guilty explanation. What do you have in mind?

One thing I must note is that the string "...@trnddc" is found only in
conjunction with Microsoft Outlook Express; I did a quick Google Groups
search. However only a minute fraction of posts from OE seem to have
this form msg-ID in the first place.

It still seems suspicious to me, but I may be making accusations without
clear evidence. In any case, regardless of the "msg-ID" issue, based on
an overall consideration of his posts to clc, I believe Bill C is a
troll. IMO of course.

<snip>

Mark L Pappin

unread,
Jul 30, 2008, 2:22:40 AM7/30/08
to
"Bill Cunningham" <nos...@nspam.com> writes:
> "Keith Thompson" <ks...@mib.org> wrote

>> A comment on your code. Why did you write
>>
>> "%i" " "
>>
>> ? Do you understand exactly what that syntax means (I'm referring to
>> the quotation marks, not the %i).
>
> Nope.

The line Keith quotes contains two string literals, "%i" and " ",
separated by nothing but whitespace ("%i"" " or "%i" " " would be
equivalent). The compiler has (as it is required to) merged them into
a single string literal "%i " and it is this which printf() was
passed.

> I had no idea what I was doing. I was hoping I would get it right
> and kept fiddling around

You've been told before: Don't Do That.
If you have no idea, ask.

I'm beginning to realise how pointless my offer to help was, but I'm
the eternal optimist here: prove them wrong, Bill; work through the
exercises I've set, post the code you come up with, tell us where
you're stuck, absorb the help that's given to you, and practice,
practice, practice. But step back from the Monte Carlo programming
technique (by which I mean "throwing random characters into source
file and hoping it does what you want") that you've already discovered
many times DOES NOT WORK.

> My text (not k&r2)

1. What is your text?
2. Get K&R2.

> said ' ' would be a space. It wasn't.

You seem to be using English the same way you use C, stringing
together words that individually are fine but in concert are
meaningless. ' ' most certainly _is_ a space, but the way in which
you used it obviously didn't produce a space in the output - what you
should do in this case is

1. Show us the code you wrote.
2. Tell us _precisely_ what you expected it to do.
3. Tell us _precisely_ what it actually did.

mlp

Barry Schwarz

unread,
Jul 30, 2008, 2:43:07 AM7/30/08
to

I don't understand headers for the most part but after BC's recent new
percentage thread and his response to RH in the q3 tutorial thread, I
have reluctantly come to the same conclusion. Even worse, the quality
of his trolling is decreasing (almost as if he were losing interest in
stringing us along).

But it does give me a chance to test a filter feature of Agent to kill
any thread he starts.

--
Remove del for email

Bill Cunningham

unread,
Jul 30, 2008, 2:53:29 PM7/30/08
to

"Keith Thompson" <ks...@mib.org> wrote in message
news:ln3alsi...@nuthaus.mib.org...

> Bill Cunningham: Do you have any comment on this? Do you know why
> your X-Newsreader: header implies you're using Outlook Express, but
> your Message-ID implies you're using trn?
>

Keith I don't think my headers are lying. I'm running old ver 6 of OE.
slrn didn't work out for me. All the newsreaders I've tried as late I
haven't been able to lock onto my news server with.
I don't use trn at all.

Bill


Bill Cunningham

unread,
Jul 30, 2008, 3:02:08 PM7/30/08
to

"Mark L Pappin" <m...@acm.org> wrote in message
news:87y73jv...@Don-John.Messina...

These questions in your tutorial Mark is indeed getting more difficult.
It may be several days before I can put together all the answers to all the
questions but I sill go one step at a time. I hope you are prepared to work
with me on some of these, the first answer will quite probably not be
correct. But what ever happens I certainly thank you for your attempts. I
will do my best on this.

Bill


santosh

unread,
Jul 30, 2008, 3:03:49 PM7/30/08
to
Bill Cunningham wrote:

Well, I'm sorry for my accusations, but forgive me if I'm not as
enthusiastic about discussing C with you as I was some weeks
previously. In any case you are still getting excellent help from
several posters.

Bill Cunningham

unread,
Jul 30, 2008, 3:05:17 PM7/30/08
to

"Keith Thompson" <ks...@mib.org> wrote in message
news:ln3alsi...@nuthaus.mib.org...

> Bill Cunningham: Do you have any comment on this? Do you know why


> your X-Newsreader: header implies you're using Outlook Express, but
> your Message-ID implies you're using trn?

I will post my headers.

Path:
nwrddc01.gnilink.net!cyclone2.gnilink.net!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc04.POSTED!12222bec!not-for-mail
From: "Bill Cunningham" <nos...@nspam.com>
Newsgroups: comp.lang.c
References: <s_shk.374$5Q.80@trnddc06> <87tzeh1...@bsb.me.uk>
<prthk.376$5Q.164@trnddc06> <87prp51...@bsb.me.uk>
<foNhk.417$_l.339@trnddc04> <87bq0od...@Don-John.Messina>
<Va5ik.507$_l.500@trnddc04> <874p6ez...@Don-John.Messina>
<87myk47...@bsb.me.uk> <s15jk.160$wS4.87@trnddc03>
<g6in1s$j8j$1...@registered.motzarella.org> <87vdyr3...@bsb.me.uk>
<g6ip7v$4eo$2...@registered.motzarella.org> <87k5f73...@bsb.me.uk>
<g6iuqq$hvk$1...@registered.motzarella.org>
<g6m0jl$d9q$1...@registered.motzarella.org> <ln3altk...@nuthaus.mib.org>
<g6mnkl$aij$1...@registered.motzarella.org> <lnwsj4i...@nuthaus.mib.org>
<cdea9ab6-0b58-45f7...@i76g2000hsf.googlegroups.com>
<ln3alsi...@nuthaus.mib.org>
Subject: Re: for and arrays
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
Message-ID: <JM2kk.567$rb5.516@trnddc04>
Date: Wed, 30 Jul 2008 18:53:29 GMT
NNTP-Posting-Host: 71.188.198.61
X-Trace: trnddc04 1217444009 71.188.198.61 (Wed, 30 Jul 2008 14:53:29 EDT)
NNTP-Posting-Date: Wed, 30 Jul 2008 14:53:29 EDT
Xref: news.verizon.net comp.lang.c:498498
X-Received-Date: Wed, 30 Jul 2008 14:53:28 EDT (nwrddc01.gnilink.net)


It is loading more messages.
0 new messages