array question

Hi,

i want to get the user to input a number, and this creates an array with the size of the number enter. i tried this

cout << "Enter number of values you wish to add" << endl;
cin >> v;

double sum[v];

this is not working. is it even possible to do this? or should i be using a List Array?

You will have to use dynamic memory:
http://www.cplusplus.com/doc/tutorial/dynamic.html
When you declare an array ,the number of its elements should be first known,so the compiler can allocate memory for it.

You may create a function whose header should be "void fun(double sum[],int i)",and the value you entered should be passed to "i".
You could use standard containers
so nothing like a ListArray that's in java for c++?

umm this is way is much more complicated
Topic archived. No new replies allowed.