|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I'm trying to create an array of varying length depending on the input of the user as demonstrated in the following code:
Code:
#include <iostream.h>
int main(void)
{
int size;
cout << "Enter array size: ";
cin >> size;
int data [size];
return 0;
}
Quote:
|
| Sponsored Links |
|
|
|
|||||
|
Your problem is just what the error says: you are not allowed to dynamically determine the size of an array that way. You will either have to use the new[] operator and a pointer, or use a container class from the STL.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Peculiar UI Problem Needs Tackling | adriyel | C# Programming | 2 | 04-06-2008 08:46 AM |
| fread into array position | kenna | C and C++ | 0 | 08-17-2007 09:03 AM |
| Having a problem with a relatively easy problem... | Yaglana | Java Help | 0 | 04-26-2007 08:33 PM |
| Python 2D array question | annannienann | Python | 3 | 04-23-2007 05:36 PM |
| Directory Size | John | PHP Forum | 5 | 08-06-2006 02:02 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |