Is it possible to get variables declared at runtime itself ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Is it possible to get variables declared at runtime itself ?

Variables

17th May 2018, 4:21 PM
Deepak Mittal
Deepak Mittal - avatar
6 Answers
+ 3
As far as I can think, there ist no possibility to declare new variables during the runtime of a program. Since it is compiled and ready to go. But more of a question would be, what you would like to do with it after generating it?
17th May 2018, 6:38 PM
Miro
Miro - avatar
+ 3
Miro...I will replace it with an array
18th May 2018, 5:10 AM
Deepak Mittal
Deepak Mittal - avatar
+ 2
Pawel be clear
18th May 2018, 5:10 AM
Deepak Mittal
Deepak Mittal - avatar
+ 1
switch(number) { case 1: pointer_int=new int; break; case 2:... ... }
18th May 2018, 11:21 AM
Pawel Bolek
Pawel Bolek - avatar
0
Okay if I got it right, you want to run your program and give it, let us say an int, then convert this int to an array? If yes you could just write a method, that gets your user input and another method that convert your int. Output should be in the main.
18th May 2018, 5:41 AM
Miro
Miro - avatar
- 1
Dynamic allocation ;-)
18th May 2018, 4:54 AM
Pawel Bolek
Pawel Bolek - avatar