You have to determine the size of the text in pixels and calculate the top and left positions for centering in a given rectangle:
int text_w = textwidth(textstring);
int text_h = textheight(textstring);
int rect_w = rect_right - rect_left;
int rect_h = rect_bottom - rect_top;
int x = rect_left + (rect_w - text_w) / 2;
int y = rect_top + (rect_h - text_h) / 2;
rectangle(rect_left, rect_top, rect_right, rect_bottom);
outtextxy(x, y, textstring);