How can I properly initialize this array?
I get this error when compiling:
In function `int main()':
error: variable-sized object `inputArray' may not be initialized
Execution terminated
1 2 3
|
int main(){
int maxSize=4;
int inputArray[maxSize]= {45, 12, 76, 100} ;
|
Either
const int maxSize=4;
or
int inputArray[]= {45, 12, 76, 100} ;
or
vector<int> inputArray = {45, 12, 76, 100};
Thanks last change here is the correct output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
C:\Dev-Cpp\Chapter11>daniwebBinaryTr
Display output using:
a)inorder traversal
b)preorder traversal
c)postorder traversal
Enter choice:a
12 45 76 100
C:\Dev-Cpp\Chapter11>daniwebBinaryTr
Display output using:
a)inorder traversal
b)preorder traversal
c)postorder traversal
Enter choice:b
45 12 76 100
C:\Dev-Cpp\Chapter11>daniwebBinaryTr
Display output using:
a)inorder traversal
b)preorder traversal
c)postorder traversal
Enter choice:c
12 100 76 45
C:\Dev-Cpp\Chapter11>
|
Topic archived. No new replies allowed.