invalid types 'int[int]' for array subscript

I wrote my code, and most of my errors are invalid types int int for array subscript and I have no idea how to fix it.

fixed
Last edited on
http://i.imgur.com/FR65EYf.png
prog.cpp:78:23: error: comparison between pointer and integer
      ('int' and 'int *')
    for (int i = 20; i>= number_size; i--)
                     ~^  ~~~~~~~~~~~
prog.cpp:80:10: error: use of undeclared identifier 'i'
    for (i = number_size - 1; i >=0; i--)
         ^
prog.cpp:80:31: error: use of undeclared identifier 'i'
    for (i = number_size - 1; i >=0; i--)
                              ^
prog.cpp:80:38: error: use of undeclared identifier 'i'
    for (i = number_size - 1; i >=0; i--)
                                     ^
prog.cpp:81:24: error: use of undeclared identifier 'i'
        cout << number[i];
                       ^
prog.cpp:91:19: error: subscripted value is not an array, pointer, or vector
        second_num[i] = 0;
        ~~~~~~~~~~^~
prog.cpp:102:12: error: subscripted value is not an array, pointer, or vector
        sum[i] = first_num[i] + second_num[i] + carry;
        ~~~^~
prog.cpp:102:43: error: subscripted value is not an array, pointer, or vector
        sum[i] = first_num[i] + second_num[i] + carry;
                                ~~~~~~~~~~^~
prog.cpp:103:16: error: subscripted value is not an array, pointer, or vector
        if (sum[i] >9)
            ~~~^~
prog.cpp:106:16: error: subscripted value is not an array, pointer, or vector
            sum[i] = sum [i] - 10;
            ~~~^~
prog.cpp:106:26: error: subscripted value is not an array, pointer, or vector
            sum[i] = sum [i] - 10;
                     ~~~ ^~
prog.cpp:117:16: error: subscripted value is not an array, pointer, or vector
            sum[0] = 0;
            ~~~^~
prog.cpp:121:16: error: subscripted value is not an array, pointer, or vector
            sum[large_size] = carry;
            ~~~^~~~~~~~~~~
13 errors generated.
I know what my errors are but I have no idea how to fix it.
Which ones do you have no idea how to fix? Those say exactly what is wrong with them. PS fix them one at a time starting from the first error.

BY the way 4 of the errors are because you didn't initalize i on line 80. Also look at your parameter on line 84 then look at how you have sum and second_num. You declare as int then try and subscript it as if it was an array.
Last edited on
Why is number_size an array of integers instead of just one integer?
Why does line 84 not match line 11?
Why are you missing "int" on line 80?
Last edited on
fixed the errors. I forgot to put an array in the function. thanks guys
fixed the errors. I found out what I did wrong. Thanks guys.
Topic archived. No new replies allowed.