when I declare array like this: char temp[size]; in the function void rotateLeft(char arr[], int size), I got the error: ISO C++ forbids variable length array 'temp'. I am very confused as isn't that how we declare array in C++? If we can't declare a variable size length array, how am I suppose to declare an array that have parameter "size" as it's length?
Asked
Active
Viewed 30 times
-2
Jack
- 1
- 2
-
7*isn't that how we declare array in C++?* Nope. Use a `std::vector`. – user4581301 May 24 '22 at 21:57
-
3Or rather, yes, as long as the size is a compile-time constant. – HolyBlackCat May 24 '22 at 22:00