What is the error here?

What is the error here?
0

What did I do wrong?

You aren’t initializing your array right. You have 5 items…

Check out an example like:

#include <iostream>
using namespace std;
 
int main () {
   // an array with 5 rows and 2 columns.
   int a[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},{4,8}};
 
   // output each array element's value                      
   for ( int i = 0; i < 5; i++ )
      for ( int j = 0; j < 2; j++ ) {
      
         cout << "a[" << i << "][" << j << "]: ";
         cout << a[i][j]<< endl;
      }
 
   return 0;
}

https://www.tutorialspoint.com/cplusplus/cpp_multi_dimensional_arrays.htm

Its fine I sorted it out another way. I extended the boundary and variablised the first.

Why would you do that? You are asking for trouble. What happens it you hit an element in the array that doesn’t exist?

Dont start with bad coding practices!

Oh, I didn’t think about that. Ok sir, won’t happen again.

Sir? Lol. Sir is my father. No need. slackmoehrle is fine :slight_smile:

We all have done stuff like this! Also, get started with error checking and try catch blocks. Often programmers forget to do error checking until it is to late. Start using assert also to help in debugging to catch ways your program might fail that you don’t realize.

https://www.tutorialspoint.com/cplusplus/cpp_exceptions_handling.htm

http://www.cplusplus.com/reference/cassert/assert/

hahahahahahah

Thanks for the tip, will definitely look up assert in the future. And I called u sir coz I assumed being called 'Slack’moehrle wasn’t a very nice thing XD