How is this even compiling? You use the name res which isn't defined anywhere; I assume you mean result.
I have some segmentation faults, can't find what is wrong
What compiler are you using? Does it report any warnings? It should.
VS2015 gives me:
main.c(78): warning C4700: uninitialized local variable 'n' used
main.c(81): warning C4700: uninitialized local variable 'array' used
main.c(83): warning C4700: uninitialized local variable 'result' used
array and result are pointers, but you never actually point them at anything, so they're pointing who knows where and that's why the segfaults. Create some MATRIX objects and use those.
could you show (in the code) how to add 'n' matrices?
First thing I'd do is refactor a little bit - make these things separate in your code:
Creating new MATRIX objects
Reading them in
This will make the problem easier to approach; your code is a bit of a mess right now.
For the addition portion, start by considering addition of simple integers. How would you do that? Here's a suggestion to start with:
int Add(int *values, int numValues)
If you can do that, then all you have to do is change int to MATRIX and figure out how to add two matrices, not n.