Solved

Dynamic Arrays

Posted on 1999-01-17
5
197 Views
Last Modified: 2010-05-18
Is there anyway in C or C++ to use initialise the size of an array at run time and also be able to change it? Thanks.
0
Comment
Question by:onka34
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1258160
malloc/realloc
0
 

Expert Comment

by:jji
ID: 1258161
Don't forget 'free' & 'calloc'.
0
 
LVL 1

Accepted Solution

by:
arunprakash earned 100 total points
ID: 1258162
try using the Standard template library.
it has classes called Deque, vector which can take care of this dynamic expanding and shrinking arrays

u can do
array.push_back(element)
element can be off any type
0
 

Expert Comment

by:bsutris
ID: 1258163
c cannot change array size but if you use pointer and you use it like an array, you can change the size of the pointer
0
 

Author Comment

by:onka34
ID: 1258164
Thanks :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c language help - file paths 7 151
Why does module make constant click noise ? 9 141
C hashtable library 3 107
C Language combined operators 28 120
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question