Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamic Arrays

Posted on 1999-01-17
5
Medium Priority
?
204 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 85

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

Technology Partners: 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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Suggested Courses

886 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