If you want to do the partial pivoting, you need to SWAP the row (rmax) that has the largest absolute element in that column with the current row (k).
You have (nearly) correctly identified rmax (smax needs to be set to the absolute value of the matrix element, which could be negative). However, I see no evidence of you doing any swapping of rows.
You are also going to run into floating-point round-off problems if you compare a calculated value with 0 to test for singularity (and return the rank).
smax = matrix[i][k];
should be smax = abs( matrix[i][k] );
What next should I do?
Show us the whole code and an input file so that we can test it.
I repeat: the following is not a good test - it is subject to floating-point round-off error. If you want the matrix rank you need a small tolerance to compare for near-zero.