In my project I’ve these files:
functions.h
functions.cc
main.cc
I’m trying to pass Matrix to functions as pointers in this way:
main.cc
// Size -> const short Size = 10;
int mtr1[Size][Size];
matrix_insert((int *)mtr1);
functions.h
void matrix_insert(int *mtr);
functions.cc
void matrix_insert(int *mtr) {
short i, j;
for (i = 0; i < Size; i++) {
for (j = 0; j < Size; j++) {
std::cin >> *(mtr + i * Size + j);
}
}
}
This is actually working but I don’t like this way…
Is there a better method?
Thanks!
EDIT:
Is possible to emulate matrix with vector?
If you really want to use C arrays, then you can do it as follows:
main.cc
functions.h
functions.cc
Working version: http://ideone.com/1ik7T9