if you want a function parameter to be populated with the result, you're right that you have to pass it in by reference using the & (if you're using C++). if you intend to stick with C, then you'll approach it in a similar way, just passing a pointer into the function instead.
instead of using a c array stuff like this tends to be much more readable with a simple struct that actually describes the data it represents so I tossed the Position struct in there as an example of that...
struct Position
{
int x{ 0 };
int y{ 0 };
};
void get_center_coordinates_cpp(const int window_width, const int window_height,
const int image_width, const int image_height, Position& pos)
{
pos.x = (int)(window_width / 2 - image_width / 2);
pos.y = (int)(window_height / 2 - image_height / 2);
}
void get_center_coordinates_c_style(const int window_width, const int window_height,
const int image_width, const int image_height, Position* pos)
{
pos->x = (int)(window_width / 2 - image_width / 2);
pos->y = (int)(window_height / 2 - image_height / 2);
}
int main()
{
Position pos1{};
get_center_coordinates_c_style(100, 100, 10, 10, &pos1);
Position pos2{};
get_center_coordinates_cpp(100, 100, 10, 10, pos2);
}