If you know the size of both matrices and those sizes will not change then it is much easier to just do:
If you have variable sized matrices and are not against using C++ then I would recommend creating a matrix class that can handle all types and sizes of matrices. You could then write generic C functions that know how to concatenate as well as IF two matrices can be concatenated.
void MatMult4x4(float mat1,float mat2,float result)
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
for (int k=0;k<4;k++)
This is the approach I used in the past before the D3DX library was widely used and available.
My matrix class would control all aspects of a matrix and I had a generic matrix library that could multiply different sized matrices together provided the sizes were provided by the caller.
There are cases in which two matrices cannot be concatenated and your code should check for this. It is not the easiest task to create an all-inclusive matrix library that can handle any size matrix. My use of matrices has always been directly linked to doing 3D graphics and as such I rarely concatenate any matrix over 4x4 or under 3x3.
In order to code a function to multiply a vector by a matrix you also must satsify certain conditions. If you know how many components a vector has and the size of the matrix then the code is easy. Coding a universal function to multiply matrices and vectors regardless of size is also not the easiest task.
This is how you multiply a 3D vector by a 4x4 matrix.
Note that this code only works for right handed coordinate systems.
void VectorMul4x4(const Vector3 in,const float Mat,Vector3 &out)
I would not create a function that did everything you wanted in one swoop. It is much easier to create several generic functions that will concatenate matrices and that will multiply vectors by matrices or more appropriately transform a vector by a matrix. If you have the Direct3D SDK you can look in the help file and it will show you how to transform matrices and vectors and the math behind it. There is also tons of information on the net about this topic. I recommend www.gamedev.net which has several articles on this topic as well as a lot of source code. Another is www.gamasutra.com which also has tons of information on this very topic. Since 3D graphics are so popular and since matrices and 3D graphics are like bread and butter, it's very easy now to find tons of resources about operations on vectors and matrices. I recommend you read up on vectors and matrices and the different operations for both before coding anything.