I want to declare an array[x]
, but I want my array's size changeable for every each new programm start. My first idea was int x; scanf("%d",&x);
one line before I declare my array[x]
but that doesent work because x have to be a const int.
My next idea was simply make a const int x; scanf("%d", &x);
but this try also failed, because
array[x]
or rather say the const int x must be initialized before I can start the programm.
My last idea was to initialized the x const int x = 1;
and on the next time scanf("%d", &x);
In this try the programm didnt crashed, but it wasnt usefull. In the moment if I start the programm my array[x]
got initialized with my "old" x. So my changed x have no impact.
Do u have any ideas how I can solve this little problem or this there no way to initialize a const int or overall a const type after I start the programm in C++?