Initialising a 2D numeric array

What is the format to initialise a 2D array(numeric) in Turbo C++ and Xcode(Command Line Tool --> C++) ?

My doubt arises because, the PC in my school which runs the Turbo C++ environment, the syntax is --
int array[rows][colms];

but SOMETIMES whilst working on my Mac at home (Xcode), the program only works when the syntax is --
int array[colms][rows];

Please help!

On a side note, is a Turbo C++ like software available for Mac or is Xcode fine ?
C and C++ do use row-major convention. Therefore:
[code]int array[ROWS][COLS];
See http://www.cplusplus.com/doc/tutorial/arrays/#multidimensional_arrays

The result should be same with all compliant compilers and IDE's.


However, that is a declaration, not initialization. Initialization sets the values of the array too.
See http://en.cppreference.com/w/cpp/language/aggregate_initialization
@keskiverto -
Sorry for the mistake in terms. I do that often even though i know the difference xP

And as a rule both school and home IDE's follow the Row Major convention. But only in few programs the compiler(Xcode) seems to function on a column major form, i.e. only then do I get the desired output.

Of course, it may also be a logical error on my part and i'll recheck the code for any mistakes although I'm pretty sure there is no error. If the problem still persists i'll paste the code-desired output- and actual output here!!

Until then, Thank You so much for the help !
Regards,
Sid P.
Topic archived. No new replies allowed.