Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamic Arrays

Posted on 1999-01-17
5
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
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 how to create, access, and change arrays in the C programming language.

705 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