I know the graphics functions typically use column major ordering: A[col][row], which matches up with things like gotoxy(x,y).
For our own arrays, I've always used A[row][col], and since it's worked, I don't quite see how it could have really been A[col][row].
I'm going to check with my K&R, but I'm sure I got the idea of A[row][col] being correct, right from them. I realize this is a conceptual thing, and that our memory is not physically laid out (and thus changed), when we change our array parameters. But conceptually is what we're talking about, not soldering on new wires in our RAM.
In this short program to parse words out of text, I use Words[row][col], for example. I use a for loop like this:
Code:
notFound = 1;
for(i = 0; i < MaxArrayRows; i++) {
if(strcmp(newlyFoundWord, Words[i]) == 0) {
notFound = 0;
break;
}
}
if(notFound)
strcpy(Words[countOfWordsFoundSoFar], newlyFoundWord);
Which puts newly found words, into the Words[][] array. If Words[i] and Words[countOfWordsFoundSoFar], did not correspond conceptually, with a pointer to a row in the Words[][] array, then why does this code work without a hitch?
The Words array is sized at Words[1000][25]. So it's not like it's a convenient square array, that would work column major or row major.
Looks like row major ordering to me.
*countOfWordsFoundSoFar is just named long for clarity, here. In the program, it's just "count".
**The book link posted above showed only "The book could not be viewed..."