Welcome to Dream.In.Code
Become a C++ Expert!

Join 150,175 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,208 people online right now. Registration is fast and FREE... Join Now!




array

 
Reply to this topicStart new topic

array

red_4900
23 Aug, 2008 - 06:07 AM
Post #1

Code T(h)inkers
****

Joined: 22 Feb, 2008
Posts: 868



Thanked: 13 times
My Contributions
how to set array with n numbers of element? is there any way to do it? is it possible?
User is offlineProfile CardPM
+Quote Post

KYA
RE: Array
23 Aug, 2008 - 06:32 AM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 5,910



Thanked: 159 times
Dream Kudos: 1375
My Contributions
off the top of my head, the closest way to do this is to declare it dynamically at run time:

cpp

//user input
int* ptr = new array[userSize];
//stuff


You cannot have uninitialized variables/data structures. The program must allocate memory and an array with 'n' elements cannot be allocated.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/9/09 03:34AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month