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


Preeti AgrawallaRank #6,677 · 259 reputationPosted Apr 24, 2015, 3:13 AM EDT
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".
Rajeev RanjanRank #373 · 6.8K reputationPosted Apr 24, 2015, 3:57 AM EDT
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.
Joe WilsonRank #631 · 3.8K reputationPosted Apr 24, 2015, 11:14 AM EDT
Atul RawatRank #507 · 4.9K reputationPosted Oct 12, 2015, 7:12 AM EDT
Priyaranjan K SRank #45 · 32.5K reputationPosted Oct 12, 2015, 8:36 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted Apr 24, 2015, 11:16 AM EDT