Answer the question
In order to leave comments, you need to log in
How to create an array with the number of elements equal to the number entered?
int s=0;
scanf_s("%d", &s);
int arr[s];
This code throws an error, because s must be declared as const. But if I declare s as const, I will not be able to change its value when entering a number using scanf_s. What construct should be used to
store a number in a variable when input and create an array with a size equal to this variable?
Answer the question
In order to leave comments, you need to log in
You need to create a dynamic array.
It wobbles once or twice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question