Re: for and arrays
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Wed, 23 Jul 2008 00:30:29 +0100
"Bill Cunningham" <nospam@xxxxxxxxx> writes:
"Ben Bacarisse" <ben.usenet@xxxxxxxxx> wrote in message
news:87tzeh1rbu.fsf@xxxxxxxxxxxx
"Bill Cunningham" <nospam@xxxxxxxxx> 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.
.
- Follow-Ups:
- Re: for and arrays
- From: Kaz Kylheku
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- References:
- for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Ben Bacarisse
- Re: for and arrays
- From: Bill Cunningham
- for and arrays
- Prev by Date: Re: Library bug or my fault?
- Next by Date: Re: for and arrays
- Previous by thread: Re: for and arrays
- Next by thread: Re: for and arrays
- Index(es):
Relevant Pages
|