a question on array! 
Author Message
 a question on array!

I am a beginner in C.

can a two-dimensional array be used as a variable which can be set in any
size according to needs?
for example, sometimes it can be 3*2, sometimes it can be 4*2, etc..
thanx!

--



Fri, 05 Oct 2001 03:00:00 GMT  
 a question on array!


Quote:
>I am a beginner in C.

>can a two-dimensional array be used as a variable which can be set in any
>size according to needs?
>for example, sometimes it can be 3*2, sometimes it can be 4*2, etc..
>thanx!

No.  You need to study dynamic arrays.  BTW there are no 2D arrays in C,
only arrays of arrays.  That isn't a quibble but an important feature of
the language.

Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
--



Sat, 06 Oct 2001 03:00:00 GMT  
 a question on array!
Then, where should I begin?
Would u please show me the way?
thanx a lot!

Quote:



>>I am a beginner in C.

>>can a two-dimensional array be used as a variable which can be set in any
>>size according to needs?
>>for example, sometimes it can be 3*2, sometimes it can be 4*2, etc..
>>thanx!

>No.  You need to study dynamic arrays.  BTW there are no 2D arrays in C,
>only arrays of arrays.  That isn't a quibble but an important feature of
>the language.

>Francis Glassborow      Journal Editor, Association of C & C++ Users
>64 Southfield Rd
>Oxford OX4 1PA          +44(0)1865 246490
>All opinions are mine and do not represent those of any organisation
>--


--



Sun, 14 Oct 2001 03:00:00 GMT  
 a question on array!


Quote:
>Then, where should I begin?
>Would u please show me the way?
>thanx a lot!

Sorry but I do not have time to write a tutorial.  However:
first go and discover how to use malloc

then use it to create an array of pointers for the first dimension
then initialise each of these pointers with malloc to provide storage
for the second dimension.

(But I think you need to learn to walk first by learning how to deal
with 1D arrays dynamically allocated with malloc)

Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
--



Tue, 16 Oct 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Question: extern *array and array[]

2. Question about array initializers, const

3. question on arrays

4. Question about arrays

5. Stupid question about array boundries

6. Question about array

7. question about array of pointers to chars

8. question about array?

9. Newbie question about arrays

10. Newbie question: Making arrays bigger

11. A question about arrays,pointers and structures

12. Question about arrays and pointers

 

 
Powered by phpBB® Forum Software