Re: for and arrays
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Tue, 22 Jul 2008 23:34:13 +0100
"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?
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.
.
- Follow-Ups:
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- References:
- for and arrays
- From: Bill Cunningham
- for and arrays
- Prev by Date: for and arrays
- Next by Date: Re: for and arrays
- Previous by thread: for and arrays
- Next by thread: Re: for and arrays
- Index(es):
Relevant Pages
|