I mean I want to ask user to enter the size of arrays when he/she uses my program instead of me, and when I use cin to get the size and put it as array size in brackets this error appear: the array size must have constant value and when I change the cin parameter as const int nothing happen, please guide me to solve this problem, Thank you.
Loading

Priyaranjan K SPosted Oct 12, 2015, 12:36 PM
Atul RawatPosted Oct 12, 2015, 11:12 AM
Joe WilsonPosted Apr 24, 2015, 3:16 PM
Joe WilsonPosted Apr 24, 2015, 3:14 PM
Rajeev RanjanPosted Apr 24, 2015, 7:57 AM
if yes then assign any value before the run your programe and use a simple logic
to assign user entered value ( something like swapping) that make your code easier and your problem gets resolved.
Preeti AgrawallaPosted Apr 24, 2015, 7:13 AM
This problem might occur, because an user is entering a string value and we can't use string value as an array size. so it will be better to use try catch block, or to check whether entered value is integer or not and provide a message to end user that "please enter numbers".