How to give to an array the dimensions of two variables? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to give to an array the dimensions of two variables?

Good morning, I wrote a code in that read a txt file and gives the value to a variable called node_number. I have to assign to an array the dimension equal to node_number. Could you help me?

30th Aug 2019, 10:44 AM
Giulio Palamà
Giulio Palamà - avatar
5 Answers
+ 2
I don’t have the code on my phone. But my question is simple. I want to allocate an array with the dimension of a variable previously defined.
30th Aug 2019, 11:01 AM
Giulio Palamà
Giulio Palamà - avatar
+ 2
Giulio Palamà I don't know how far have you gone through the C++ lesson, just in case you haven't got to the "Dynamic Memory" chapter, where dynamic array allocation is covered, here's the lesson link: https://www.sololearn.com/learn/CPlusPlus/1632/
30th Aug 2019, 11:20 AM
Ipang
+ 1
Hello Giulio Palamà Can you share your code in the Description section? it would be rather hard for others to help you without looking at the code. See if you can open this link, it's a guide for sharing content links around SoloLearn. https://www.sololearn.com/post/74857/?ref=app
30th Aug 2019, 10:54 AM
Ipang
+ 1
thanks!!
30th Aug 2019, 11:51 AM
Giulio Palamà
Giulio Palamà - avatar
0
int ArraySize; cout<<"Enter array Size: ";cin>>ArraySize; int Array; Array = new Int[ ArraySize ]; delete [] Array;
31st Aug 2019, 5:49 AM
Tobi PL
Tobi PL - avatar