Solved

Dynamic Arrays

Posted on 1999-01-17
5
190 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now